fyusuf-a
fyusuf-a

Reputation: 255

Drop xml declaration in libxml2

I want to get rid of the xml declaration when I use libxml2's function xmlSaveFile. How can I accomplish that ? Is there any macro to do that or can I use another function (I tried with xmlSaveToFilename from xmlsave.h but I do not know how it works) ?

Upvotes: 1

Views: 825

Answers (1)

nwellnhof
nwellnhof

Reputation: 33658

Something like this should work:

xmlSaveCtxtPtr saveCtxt = xmlSaveToFilename(filename, NULL, XML_SAVE_NO_DECL);
if (saveCtxt == NULL) {
    // Error handling
}
if (xmlSaveDoc(saveCtxt, doc) < 0) {
    // Error handling
}
xmlSaveClose(saveCtxt);

The documentation of the xmlsave module can be found here.

Upvotes: 3

Related Questions