Search code examples
objective-cxmlcocoansxmlelement

Writing to XML in Cocoa


is it possible to write to an XML file that I've read from without using an external library ? I have read about writing using things KissXML, but I would like to write without anything extra.

So if I have an NSXMLElement or an NSXMLDocument in memory, how would I go about changing one of its nodes?

Thanks


Solution

  • Try to read apples docs at: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/NSXML.html#//apple_ref/doc/uid/TP40001269

    1. You need get node for change (using traverse tree or query node via XPath).
    2. Change node as you wish.

    You can write xml data to file as a string after call XMLStringWithOptions for document.