Vaishnavi Naidu
Vaishnavi Naidu

Reputation: 2617

how to create an xml using objective-C with respect to data storage?

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?

Upvotes: 1

Views: 2712

Answers (2)

pxl
pxl

Reputation: 1297

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.

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96927

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

Upvotes: 1

Related Questions