tadija / AEXML

Swift minion for simple and lightweight XML parsing
MIT License
1.01k stars 200 forks source link

Ability to exclude standalone attribute from document header #179

Closed sskjames closed 3 years ago

sskjames commented 3 years ago

First of all, thank you very much for this library. I observed that the attribute "standalone=yes/no" is added to the document header. <?xml version="1.0" encoding="utf-8" standalone="no"?> I checked the source code and it looks like there is no option to prevent this attribute from being written to the final xml string. Is it possible? I would like to have it this way: <?xml version="1.0" encoding="utf-8"?> Unfortunately, I'm generating a xml file which would be consumed by another application and the integration doesn't work when the "standalone" attribute is included in the document header.

tadija commented 3 years ago

Hi @sskjames, you could override xml property of AEXMLDocument and use a custom header like this:

open override var xml: String {
    var xml =  "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
    xml += root.xml
    return xml
}
sskjames commented 3 years ago

Thanks @tadija for the swift response. I'll try that out.

sskjames commented 3 years ago

It worked. Thanks for the help.