Create XML file dynamically in Iphone
I want to create a xml file dynamically for my Iphone application. I tried it b开发者_StackOverflow社区y using NSXMLDocument but NSXMLDocument is not declared in iphone application.
Please help me in doing so.
Thanks
Gaurav
Try the open source XML stream writer for iOS:
- Written in Objective-C, a single .h. and .m file
- One @protocol for namespaces support and one for without
Example:
// allocate serializer
XMLWriter* xmlWriter = [[XMLWriter alloc]init];
// start writing XML elements
[xmlWriter writeStartElement:@"Root"];
[xmlWriter writeCharacters:@"Text content for root element"];
[xmlWriter writeEndElement];
// get the resulting XML string
NSString* xml = [xmlWriter toString];
This produces the following XML string:
<Root>Text content for root element</Root>
You can use KissXML to generate XML files on the iPhone.
You can also use libxml2 to generate XML data on the iPhone.
精彩评论