I'm having a difficult time determining while iterating each node in an XML document (recursively) determining if the current node has a value, or, if it has embedded XML.
It seems that XmlNode.NodeType is set to Element in both cases, and in cases where the XML has a value (and not more XML) the ChildNodes.Count is not null (actually, it's 1).
A simple XML file I'm using for testing is:
<body>Check out this cool data!</body>
<distance>54 million kilometers</distance>
I don't know if you can use
System.Xml.Linq.XElement instead of
XmlDocument here but if you can, you can go about this the following way:
var xml = XElement.Parse("<note> .... </note>");
5 the correct number of subnodes, whereas
0 because the
to node has zero children...