views:

619

answers:

2

Hello,

I want to save user generated data in an XML file in the iphone. While we have NSXMLParser to parse through any xml from a url, do we have any method to create a xml file which can be stored in the app documents directory, so that i can use the parser to read the file and then display the contents back in the app.

Or using Core Data is the last resort?

+1  A: 

Look into libxml2 and, specifically, xmlTextWriter. Lots of examples available through Google.

Alex Reynolds
@Alex Reynolds: that was pretty useful,thanks. just one confirmation though, I just need to import this framework into my project using Add Framework, correct?
CodeWriter
Take a look at http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html for some setup tips.
Alex Reynolds
+1  A: 

Look into NSCoder & NSKeyedArchiver. for example with NSDictionary, you can do:

  • (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag

it'll write out the data as a plist. plists are in XML format.

pxl