Say I have these Xml tag:
I want to use the childNode method to do for example:Code:<hi help=”example”> <how> <to>do</to> <or> <give suggestion=”on” doing=”it”/> </or> <thank>bye</thank> </how> <how> … </how> </hi>
I can use the above code to get the content of to, thank, suggestion and doing...but how to get back the same content if i change the Xml tag to:Code:Dim xdoc As XmlDocument Dim nodelist As XmlNodeList Dim node As XmlNode Dim to, thank, suggestion, doing As String xdoc = New XmlDocument xdoc.LoadXml("example.xml") nodelist = xdoc.SelectNodes("/hi/how") For Each node In nodelist to = node.ChildNodes.Item(0).InnerText thank = node.ChildNodes.Item(2).InnerText listbox.Items.Add( to & thank) Dim giveNode As XmlNode = node.ChildNodes.Item(1).ChildNodes.Item(0) suggestion = giveNode.Attributes(0).Value doing = giveNode.Attributes(1).Value listbox.Items.Add( suggestion & doing) Next
ThanksCode:<hi help=”example”> <how to=”do”> <give suggestion=”on” doing=”it”/> <thank>bye</thank> </how> <how> … </how> </hi>


Reply With Quote
