Question

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) ?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top