I am having difficulty figuring out how to "properly" parse an XML response in Visual Basic. I happen to be running Visual Studio 2013. The response I get from the API I am querying looks exactly like this (some data changed to protect the innocent):

```
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<person id="123456">
    <hos-status as-of="2015-05-20T18:53:39.592Z">
        <duty-status>ON</duty-status>
        <availability>
            <drive>22020000</drive>
            <shift>22020000</shift>
            <cycle>151320000</cycle>
        </availability>
        <rest-break>
            <max-drive>420000</max-drive>
            <rest-remaining>1800000</rest-remaining>
        </rest-break>
        <daily-log-summary date="2015-05-20">
            <duty-status code="OF">25200000</duty-status>
            <duty-status code="SL">0</duty-status>
            <duty-status code="DR">7800000</duty-status>
            <duty-status code="ON">20580000</duty-status>
        </daily-log-summary>
        <daily-log-summary date="2015-05-19">
            <duty-status code="OF">51600000</duty-status>
            <duty-status code="SL">0</duty-status>
            <duty-status code="DR">8580000</duty-status>
            <duty-status code="ON">26220000</duty-status>
        </daily-log-summary>
    </hos-status>
    <location as-of="2015-05-20T18:52:40.000Z">
        <position lat="12.345678" lon="-12.345678" accuracy="3"/>
        <speed>12</speed>
        <bearing>123.45</bearing>
    </location>
</person>

```

I can parse it but the way I am doing it is certainly not intuitive. I have spent several days reading up on it and all I can find are ways that look about as ugly as what I am doing. Obviously I am missing something fundamental and I'd like suggestions on what to read so I can learn the proper way.

Here is the code / process I am using. First I call the API to get a response via the following function:

```
Public Function getCurlXML(theURL As String) As Xml.XmlDocument
    getCurlXML = New Xml.XmlDocument
    Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
    wHeader.Clear()
    Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(theURL), HttpWebRequest)
    wRequest.ContentType = "text/xml"
    wRequest.Headers = wHeader
    wRequest.Method = "GET"
    Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)
    Dim sResponse As String = ""
    Using srRead As New StreamReader(wResponse.GetResponseStream())
        sResponse = srRead.ReadToEnd()
    End Using
    getCurlXML.LoadXml(sResponse)
End Function

```

Below is the code I use to call the above function and the do the parsing:

```
Public Function getThePersonStatus(personID As String) As Collection
    Dim statusColl As New Collection
    Dim sUrl As String = "https://api.THE.com/api/stuffage/" & personID & "/status?apiKey=" & My.Settings.TheAPIKey
    Dim doc As Xml.XmlDocument = getCurlXML(sUrl)
    Dim statusElemList As XmlNodeList = doc.GetElementsByTagName("hos-status")
    For Each thisNode As XmlNode In statusElemList
      If (thisNode.Name = "hos-status") Then
          statusColl.Add(thisNode.Attributes("as-of").Value.ToString, "hos-as-of")
          statusColl.Add(thisNode("duty-status").InnerText.ToString, "duty-status")
          Dim availElem As XmlNode = thisNode("availability")
          statusColl.Add(availElem("drive").InnerText.ToString, "drive")
          statusColl.Add(availElem("shift").InnerText.ToString, "shift")
          statusColl.Add(availElem("cycle").InnerText.ToString, "cycle")
      End If
    Next
    Dim locationElemList As XmlNodeList = doc.GetElementsByTagName("location")
    For Each thisNode As XmlNode In locationElemList
      statusColl.Add(thisNode.Attributes("as-of").Value.ToString, "loc-as-of")
      statusColl.Add(thisNode("speed").InnerText.ToString, "speed")
      statusColl.Add(thisNode("bearing").InnerText.ToString, "bearing")
      statusColl.Add(thisNode("position").Attributes("lat").Value.ToString, "lat")
      statusColl.Add(thisNode("position").Attributes("lon").Value.ToString, "lon")
      statusColl.Add(thisNode("position").Attributes("accuracy").Value.ToString, "gps-accuracy")
    Next
    getThePersonStatus = statusColl
End Function

```

Basically I create an XML document from the response then I search for an element that I am interested in and then loop through that element looking for sub nodes that I am interested in.

Is there not a way to load the document and the refer to a specific element in a form similar to:

```
doc.Elem("person").Elem("hos-status").Elem("availability").Elem("Shift").InnerText

```

I know what elements are there (or should be there) but cannot seem to reference them directly no matter what I try.