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?
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?
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.