Link to home
Start Free TrialLog in
Avatar of DaneBigham
DaneBighamFlag for United States of America

asked on

Parsing XML in VB.Net

I'm attempting to parse an XML document (see attachment) in VB.Net.  Unfortunately, I'm having trouble identifying the nodes for which I'd like to parse elements.  Here's my current code:

        
        Dim xmlDoc As New XmlDocument
        xmlDoc.Load("c:\temp\XMLSample.xml")
        Dim nodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/Employees/Employee")
        Dim strField1 As String = "", strField2 As String = "", strField3 As String = ""
        For Each node As XmlNode In nodes
            strField1 = node.SelectSingleNode("FirstName").InnerText
            strField2 = node.SelectSingleNode("LastName").InnerText
            strField3 = node.SelectSingleNode("Address").InnerText

        Next

Open in new window


However, the code within the 'For Each' was bypassed.  I also tried "/EmployeeResponse/Employees/Employee") to SelectNodes, but got the same result.

Any help is greatly appreciated.XMLSample.xml
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America 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
@DaneBigham, did my post answered your question?

Fernando