XML parsing in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

<list>
<object-array>
<org.germic.web:isis.germ:Name>
<nid>260141</nid>
<gid>110</gid>.......
</org.germic.web:isis.germ:Name>
<org.germic.web:isis.germ:Details>
<gid>110</gid>
<methn>101</methn>.....
</org.germic.web:isis.germ:Details> .......
</object-array>
</list>

could anyone tell me how to parse this xml in a XmlReader or XmlDocument and
get the leaf values (nid, gid, methn etc) into a structure?

Thanks!
 
If u r using XmlReader just keep the last NodeName in a string . If the
Endelement node name is equal to the name in the string u know its a leaf.
In XmlDocument traverse the tree recursively and if any node does not have
child it is a leaf node

Saurabh
 
Thanks Sharma,

Also, to parse the sample XML have I to loop through the entire XML string
twice. Once to get the Name structure and then again to get the Details
structure? by using the SelectNodes of the XmlDocument?

Any small code snippet would be appreciated. Thanks
 
Back
Top