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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
make it xmlString = xmlString.Replace(">US<", ">United States<")
to be sure it is only in element content
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
xmlString = xmlString.Replace("US", "United States")