I'm reading the following XML text from a file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SampleXML>...</SampleXML>
and I load the UTF-8 text using IXMLDomDocument::loadXML. Then I manipulate the XML and call IXMLDomDocument::Getxml() to get a _bstr_t of the modified XML. this _bstr_t looks as follows:
<?xml version="1.0" standalone="yes"?>
<ModifiedSampleXML>...</ModifiedSampleXML>
The encoding="UTF-8" attribute in the header is gone. However, if I call IXMLDomDocument::save(FileName) to save the XML to a file, when I open the file I see that the encoding="UTF-8" attribute is preserved.
Why the encoding="UTF-8" attribute is not there when I call Getxml()? How do I tell MSXML to always preserve this attribute? (not only upon save)
No comments:
Post a Comment