开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜