Link to home
Start Free TrialLog in
Avatar of shwaqar82
shwaqar82

asked on

how can i traverse and edit each xml node data using vb.net

Hi

Is there any code in vb.net that traverse through each and every node allow us to change on any specific. I need to traverse each node if exist and their child nodes if exist and need to modify that specific node content. e.g. US to United States
Xml sample:

 <GATE>
  <GAT>Q</GAT>
  <GA>Mon</GA>
    <DEST>
     <GR>
       <GC>15</GC>
       <GN>All</GN>
      </GR>
      <GR>
        <GC>15</GC>
        <GN>Cuba</GN>
          <DES>
            <DE>
                <DC>15</DC>
                <DN>US</DN>
            </DE>
          </DES>
      </GR>
    </DEST>
 </GATE>

Regardless of how deep the xml is ..i need to traverse each node and its child node and so on ... any vb.net code sample would help me

Thanks
Shaukat

ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One other quickie method... If you have the XML in a string variable, you can use the string methods:

xmlString = xmlString.Replace("US", "United States")
But that could be dangerous if the text searched for is in the tags of the nodes and not in the data.... I would not use this unless I knew exactly what the possibilities were.
> xmlString = xmlString.Replace("US", "United States")

make it xmlString = xmlString.Replace(">US<", ">United States<")
to be sure it is only in element content
Forced accept.

Computer101
EE Admin