VB.NET - Parsing through the XML and to read the values from nodes based on the node name passed

Asked By shanmugam on 25-Jan-13 05:38 AM
Hi ..

I hav a xml like this
<?xml version ="1.0" encoding ="uft-8">
<Configration>
   <Config>
      <hostname>
       <Animals>
        <name></name>
        <color></color>
        <weight></weight>
       </Animals>
       <Human>
          <name></name>
          <color></color>
          <weight></weight>
       </Human>
      </hostname>
   </Config>
 </Configration>


i hav a method in that i wil be reading this xml...the method has the parameter that contains value "animal" or "human"
i need to read the values from the nodes based on the paramaterthat i pass


thanks in advance
Danasegarane Arunachalam replied to shanmugam on 25-Jan-13 06:45 AM
Use this Xpath to Parse the XML

/Configration/Config/hostname/

And if you pass like

/Configration/Config/hostname/Animals

Then this will get the Animal Nodes

If you pass like
/Configration/Config/hostname/Human

This will get the Human Nodes.


Refer the MSDN Article how to use Xpath

http://support.microsoft.com/kb/308333