ioslibxml2kissxml

How to remove xml declaration from KISSXML?


I'm using KissXML (iOS) to create a xml document. Everything works great but when I want to write DOM to NSString using XMLString method, then output xml string contains xml declaration (<?xml version="1.0" encoding="UTF-8" ?>). Is there any way to remove this declaration from the generated xml string?

Thanks


Solution

  • I've found that instead of invoking XMLString method on the DDXMLDocument object, you can invoke XMLString method on the rootElement so: Instead of (where xml is DDXMLDocument):

    NSString* str=[xml XMLString];
    

    use this:

    NSString* str=[[xml rootElement] XMLString];
    

    Result is an entire xml document without xml declaration.