-5

I am creating xml file using GDataXMLDocument Library. Its creating xml file like below image:

But I would like to create this file in proper format as like below Image:

How do you format XML files like this using swift?

Kara
  • 6,115
  • 16
  • 50
  • 57
Jigar Tarsariya
  • 3,189
  • 3
  • 14
  • 38

1 Answers1

0

Ok, finally I solved this question by myself.

Edit GDataXMLNode.m to make it pretty-print XML by default

Open GDataXMLNode.m, and find method - (NSString *)XMLString

Replace: int format = 0 with int format = 1;

then write code like below in Swift:

let document : GDataXMLDocument = GDataXMLDocument(rootElement: rootElement)
let xmlString : String = GDataXMLDocument.prettyPrintXML(NSString(string:document.rootElement().XMLString()) as String)

This is working fine.

Antti29
  • 2,953
  • 12
  • 34
  • 36
Jigar Tarsariya
  • 3,189
  • 3
  • 14
  • 38