You haven't posted the code you are using, so I'm only guessing, but I bet that what's happening is that this XML:
Consists of 3 nodes, not the 1 or 2 you might expect. The following information describes both how the XmlTextReader
views it and the more versatile and (in my opinion) easier-to-use XmlDocument
is represented with a type of XmlNodeType.Element
is actually considered a node by both XmlTextReader
; it has a node type of XmlNodeType.Text
, and it's Value
property will be what you expect. The </element>
node is interpreted as a node with type XmlNodeType.EndElement
and I believe XmlDocument
doesn't really return this node.
My guess is you are trying to print the value of one of the element nodes, and by definition they cannot have a value. If you could post code that is representative of what you are doing, you'd get a lot more help.