.NET, XML and comments in InnerXml
I am working on a project using old XML files developed way back when and we are trying to develop a new application to create these files. I'm currently using XmlDocument, and I am using a string as the template when I create the inner xml.
Here is an example of the original XML which we are trying to reproduce:
<Animal>
<Species>2368<!-- Mammal --></Species>
</Animal>
Now, in the inner xml there originally is a comment so that we can easily look at the XML and tell what the enumeration number maps too. When I attempt to import this as a string through into an XmlNode, it produces this on the output
<Species>2368<!-- Mammal --></Species>
InnerText shows it correctly, which makes me think that the Xml Parser is parsing it as text and translating these characters.
I thought about adding a comment node before the 'Species' node specifying what the value meant, but I'm pretty confident that will FUBAR the old XML parsing code. Whats the best way to tell XmlDocument to use the text as is?
链接地址: http://www.djcxy.com/p/66004.html