Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate XML files with swift

Tags:

xml

swift

How can I create XML files "manually" using swift? Is there any library that I can use? I saw that in objc it's possible to add libxml but even with that I can't find any good documentation on it. Any suggestions?

like image 276
Nuno Avatar asked Jul 25 '14 11:07

Nuno


1 Answers

You could use XMLDocument to write XML. For example:

import Foundation
let root = XMLElement(name: "root")
let xml = XMLDocument(rootElement: root)
root.addChild(XMLElement(name: "foo", stringValue:"bar"))
print(xml.xmlString)
like image 79
Arkku Avatar answered Oct 12 '22 07:10

Arkku