ixmldomdocument

Saving a IXMLDOMDocument without end tag

人走茶凉 提交于 2019-12-08 06:21:16
问题 Using MSXML via C++, when I call IXMLDOMDocument::save , empty XML elements will get an end tag, like this: <root> <child name="first"> </child> </root> But I want it saved as this: <root> <child name="first" /> </root> What do I need to do to accomplish that? 回答1: DOM itself does that if there are no child nodes but I don't know why in your case it is doing like this. If you want to do explicitly call Pretty Print on the DOM pointer. #include <msxml2.h> bool FormatDOMDocument

Saving a IXMLDOMDocument without end tag

♀尐吖头ヾ 提交于 2019-12-08 03:21:27
Using MSXML via C++, when I call IXMLDOMDocument::save , empty XML elements will get an end tag, like this: <root> <child name="first"> </child> </root> But I want it saved as this: <root> <child name="first" /> </root> What do I need to do to accomplish that? DOM itself does that if there are no child nodes but I don't know why in your case it is doing like this. If you want to do explicitly call Pretty Print on the DOM pointer. #include <msxml2.h> bool FormatDOMDocument (IXMLDOMDocument *pDoc, IStream *pStream) { // Create the writer CComPtr <IMXWriter> pMXWriter; if (FAILED (pMXWriter