You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Michel Voide <Mi...@linkvest.com> on 2000/12/07 16:29:36 UTC
save method in COM
Hi all,
I'd like to save an XML document to the disk with the COM version of Xerces
1.3, which provides this functionality. I have parsed an XML document which
contains an XML-DECL at the beginning, but when I save this document again,
the XML-DECL is stripped. I guess this is due to the fact that we iterate
over the document's child whereas the XMLDECL is a node located before the
the document node. Anybody has an idea how I could save the XMLDECL ?
Thanks for the help
com/XMLDOMDocument.cpp line 1398
DOM_NodeList childs = m_Document.getChildNodes();
int length = childs.getLength();
for (int i=0; i < length; ++i) {
DOM_Node child = childs.item(i);
GetXML(child,text);
}
Michel
Re: save method in COM
Posted by Curt Arnold <ca...@houston.rr.com>.
The Microsoft XML implementation treats the XML declaration as if it were a
processing instruction, which it is not (it just looks like one). The
Xerces-C implementation (which the Xerces-COM is just a wrapper) does the
right thing by not creating a PI node in the DOM.
Basically, there is no information to be preserved from the XML declaration
that is read in. If you had specified an encoding, it is no longer valid on
serialization since the serializer writes out everything in UTF-8. The only
other piece of information is the XML version and till there is another
valid value other than "1.0", that doesn't add any information either.