I am using the following code to get an XML data from a website of mine:
Dim strUrl As String = "http://www.xxx.net/mobileApp/checker.asp"
Dim reader As XmlTextReader = New XmlTextReader(strUrl)
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Text 'Display the text in each element.
Console.WriteLine(reader.Value)
End Select
Loop
Console.ReadLine()
My XML file looks like this:
<mobileApp>
<jobid>513220</jobid>
<ncdid>02132265</ncdid>
<ncddescript>blah blah and more blah</ncddescript>
</mobileApp>
Problem being is that, although it does show the text within the tags, i am looking to find the tags name and THEN get the text that’s associated with it instead of just relying on the data to always be in the same order all the time.
Example of what i am looking for:
case tags "jobid" msgbox "jobid is " & tags.jobid.value etc....
Any help would be great!
Thanks!
Since the XMLTextReader reads the file sequentially, the Element name will be displayed right before its value. Keep track of it in a string variable and do your select case from that.