VB.net - Getting Data from an XML File



I am trying to write a small program to get some data from an XML file which is already being used by another application (NOT MY OWN).


The XML Looks like this ...


?xml version="1.0" encoding="utf-8"?


sunjournal


rvcmappings default="MISSING"



rvcmap unitId="2" rvcnum="443" /

rvcmap unitId="3" rvcnum="103" /

rvcmap unitId="5" rvcnum="701" /


/rvcmappings


/sunjournal


I am trying to use the below Code in VB to get the "rvcnum" for the UnitId of 5.



Dim doc As XmlDocument = New XmlDocument()
doc.Load("C:\BootDrv\Aloha\RptExport\GLMapping_Master.xml")
Dim acc As String = doc.SelectSingleNode("sunjournal/rvcmappings/rvcmap[UNitId='5']/rvcnum").InnerText


msgbox(acc)


Can anyway point me in the right direction as I do not receive any Errors in Runtime just doesn't show the any Msgbox Data??


Many Thanks Rob


No comments:

Post a Comment