XmlDocument.InnerXml is null, but InnerText is not
- by Adam Neal
I'm using XmlDocument and XmlElement to build a simple (but large) XML document that looks something like:
<Widgets>
<Widget>
<Stuff>foo</Stuff>
<MoreStuff>bar</MoreStuff>...lots more child nodes
</Widget>
<Widget>...lots more Widget nodes
</Widgets>
My problem is that when I'm done building the XML, the XmlDocument.InnerXml is null, but the InnerText still shows all the text of all the child nodes.
Has anyone ever seen a problem like this before? What kind of input data would cause these symptoms? I expected the XmlDocument to just throw an exception if it was given bad data.
Note: I'm pretty sure this is related to the input data as I can only reproduce it against certain data sets. I also tried escaping the data with SecurityElement.Escape but it made no difference.