Simple XML parsing question

  • Thread starter Thread starter Vegard Beider
  • Start date Start date
V

Vegard Beider

Hi.

I am new to both C# and XML parsing. I simply want to find out if a
node contains other nodes, and if it does i want to do something with
it. How can i find out in a simple way that in the example below both
<data> and <moredata> contains other nodes? I have been using both the
XPathNavigator and the XMLNodeReader without finding a cleaver way of
doing this...

XML example:

<data>
<elem>val<elem>
<elem>val<elem>
<moredata>
<elem>val<elem>
</moredata>
</data>
 
Vegard said:
Hi.

I am new to both C# and XML parsing. I simply want to find out if a
node contains other nodes, and if it does i want to do something with
it. How can i find out in a simple way that in the example below both
<data> and <moredata> contains other nodes? I have been using both the
XPathNavigator and the XMLNodeReader without finding a cleaver way of
doing this...

XML example:

<data>
<elem>val<elem>
<elem>val<elem>
<moredata>
<elem>val<elem>
</moredata>
</data>

You can either use the XmlNode.HasChildNodes property or the
XmlNodeReader.IsEmptyElement property
 
Ed Courtenay said:
You can either use the XmlNode.HasChildNodes property or the
XmlNodeReader.IsEmptyElement property

I tried using the IsEmptyElement none of the above nodes are empty
since they have a value, i want to know if a node contains other
nodes..
 
Back
Top