Is there a way to loop through an XML file and retrieve desired data from elements and attributes?
I wrote a little app that is supposed to do this, but it only returns duplicate data from the first element it encounters.
Here is the code:
Thanks!Code:Dim REMdoc As New XmlDocument() REMdoc.Load(path + "remodel.xml") Dim REMnav As XPathNavigator = DAMdoc.CreateNavigator() Dim SelectedNode As XPathNavigator For Each SelectedNode In REMnav.[Select]("//ns1:reNode", nsmgr) xmlNodeId = SelectedNode.SelectSingleNode("//ns1:reNode/@id", nsmgr).Value xmlNodeTitle = SelectedNode.SelectSingleNode("//ns1:reNode/@label", nsmgr).Value 'xmlNodeContentPath = node.SelectSingleNode("//ns1:reNode/Content", nsmgr).Value query = REMnav.Compile("//ns1:ActivityNode/Content") Response.Write("<b>node Id:</b> " & xmlNodeId.ToString) Response.Write("<br><b>node Title:</b> " & xmlNodeTitle.ToString & "<br>") Response.Write("<b>node Content:</b> " & query.ToString & "<br><br>") Response.Write(query.ToString & "<br>") Next




Reply With Quote