Create XML file dynamically in Iphone

后端 未结 3 781
猫巷女王i
猫巷女王i 2020-12-03 23:57

I want to create a xml file dynamically for my Iphone application. I tried it by using NSXMLDocument but NSXMLDocument is not declared in iphone application.

Please

相关标签:
3条回答
  • 2020-12-04 00:16

    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>
    
    0 讨论(0)
  • 2020-12-04 00:36

    You can use KissXML to generate XML files on the iPhone.

    0 讨论(0)
  • 2020-12-04 00:37

    You can also use libxml2 to generate XML data on the iPhone.

    0 讨论(0)
提交回复
热议问题