Home > DeveloperSection > Forums > Read all nodes and elements in XML (VB.net)
Andrew Deniel
Andrew Deniel

Total Post:29

Posted on    June-11-2013 8:33 AM

 VB.Net VB.Net 

 1 Reply(s)
 4750  View(s)
Rate this:
Hi Expert,

I'm trying to read an xml file, there is no problem to doing this

But, in this case I will not know anything about this xml file, I just want to read everything, including all child nodes and get the name and value from each node.

This code gives me only the name of the first node and skips all children:

Dim xml As New XmlDocument
For Each node As XmlNode In xml.DocumentElement.SelectNodes("*")

Since i don't know dept or anything, i don't know how I will do this. And every solution I find is based by knowing element names.

Thanks in advance. 


Total Post:604

Posted on    June-12-2013 7:26 AM

Hi Andrew,

You can try as following

Dim xml As New Xml.XmlTextReader(sFilePath)

While xml.Read
    If xml.NodeType = Xml.XmlNodeType.Element Then 
    End If
End While

I hope it resolve your problem. 

Don't want to miss updates? Please click the below button!

Follow MindStick