Hi...
I just noticed something that seems counter-intuitive to me. By default an
XmlDocument is set with PreserveWhitesp ace=false. This means that
XmlDocument.Loa d() or .LoadXml() will strip/condense non-semantic whitespace.
*But* I just found that if you take that self-same XmlDocument and do either
XmlDocumentFrag ment node = doc.CreateDocum entFragment();
node.InnerXml = "<foo/>\r\n<bar/>";
or
XmlElement node = doc.CreateEleme nt("baz");
node.InnerXml = "<foo/>\r\n<bar/>";
that the whitespace gets preserved, despite the parent document settings.
What's the rationale for this?
Thanks
Mark
I just noticed something that seems counter-intuitive to me. By default an
XmlDocument is set with PreserveWhitesp ace=false. This means that
XmlDocument.Loa d() or .LoadXml() will strip/condense non-semantic whitespace.
*But* I just found that if you take that self-same XmlDocument and do either
XmlDocumentFrag ment node = doc.CreateDocum entFragment();
node.InnerXml = "<foo/>\r\n<bar/>";
or
XmlElement node = doc.CreateEleme nt("baz");
node.InnerXml = "<foo/>\r\n<bar/>";
that the whitespace gets preserved, despite the parent document settings.
What's the rationale for this?
Thanks
Mark
Comment