سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top