문제

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