Create XML file dynamically in Iphone

后端 未结 3 794
猫巷女王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:

    Text content for root element
    

提交回复
热议问题