title: Get XML Node Data
body: <p>I am new to XML and am trying to get some of the information from this XML document:
  <a href="http://pastebin.com/S7eUNmL2" rel="nofollow">http://pastebin.com/S7eUNmL2</a></p>
  
  <p>Using this code:</p>
  
  <pre><code>    Dim Document As New XmlDocument
      Document.LoadXml(xml)
      Dim DocumentElement As XmlElement = Document.DocumentElement
      Dim ResourceSets As XmlNode = DocumentElement.ChildNodes.ItemOf(6)
      Dim ResourceSet As XmlNode = ResourceSets.ChildNodes(0)
      Dim Resource As XmlNode = ResourceSet.ChildNodes(1)
      Dim LocationList As XmlNodeList = Resource.ChildNodes
      Dim Location As XmlNode = LocationList.ItemOf(0)
      Dim Name As String = Location.SelectSingleNode("Name").Value
  </code></pre>
  
  <p>But I get an Object reference not set to an instance of an object. exception on the last line of code.  If I quickwatch the Location value it is the correct node, but I'm at a loss of what to do... </p>
  
  <p>The XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1"&gt;
    &lt;Copyright&gt;
      Copyright © 2012 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.
    &lt;/Copyright&gt;
    &lt;BrandLogoUri&gt;
      http://dev.virtualearth.net/Branding/logo_powered_by.png
    &lt;/BrandLogoUri&gt;
    &lt;StatusCode&gt;200&lt;/StatusCode&gt;
    &lt;StatusDescription&gt;OK&lt;/StatusDescription&gt;
    &lt;AuthenticationResultCode&gt;ValidCredentials&lt;/AuthenticationResultCode&gt;
    &lt;TraceId&gt;e0aabdfcf9f746a39a4f3036b319720c|CPKM001259|02.00.83.500|CPKMSNVM001571, CPKMSNVM001585, CPKMSNVM001584, CPKMSNVM001587, CPKMSNVM001527, CPKMSNVM001502, CPKMSNVM001503&lt;/TraceId&gt;
    &lt;ResourceSets&gt;
      &lt;ResourceSet&gt;
        &lt;EstimatedTotal&gt;5&lt;/EstimatedTotal&gt;
        &lt;Resources&gt;
          &lt;Location&gt;
            &lt;Name&gt;Perth, Australia&lt;/Name&gt;
            &lt;Point&gt;
              &lt;Latitude&gt;-31.953020095825195&lt;/Latitude&gt;
              &lt;Longitude&gt;115.85723876953125&lt;/Longitude&gt;
            &lt;/Point&gt;
            &lt;BoundingBox&gt;
              &lt;SouthLatitude&gt;-32.301349639892578&lt;/SouthLatitude&gt;
              &lt;WestLongitude&gt;115.20664978027344&lt;/WestLongitude&gt;
              &lt;NorthLatitude&gt;-31.608610153198242&lt;/NorthLatitude&gt;
              &lt;EastLongitude&gt;116.52772521972656&lt;/EastLongitude&gt;
            &lt;/BoundingBox&gt;
            &lt;EntityType&gt;PopulatedPlace&lt;/EntityType&gt;
            &lt;Address&gt;
              &lt;AdminDistrict&gt;WA&lt;/AdminDistrict&gt;
              &lt;CountryRegion&gt;Australia&lt;/CountryRegion&gt;
              &lt;FormattedAddress&gt;Perth, Australia&lt;/FormattedAddress&gt;
              &lt;Locality&gt;Perth&lt;/Locality&gt;
            &lt;/Address&gt;
            &lt;Confidence&gt;High&lt;/Confidence&gt;
            &lt;MatchCode&gt;Good&lt;/MatchCode&gt;
            &lt;GeocodePoint&gt;
              &lt;Latitude&gt;-31.953020095825195&lt;/Latitude&gt;
              &lt;Longitude&gt;115.85723876953125&lt;/Longitude&gt;
              &lt;CalculationMethod&gt;Rooftop&lt;/CalculationMethod&gt;
              &lt;UsageType&gt;Display&lt;/UsageType&gt;
            &lt;/GeocodePoint&gt;
          &lt;/Location&gt;
          &lt;Location&gt;
            &lt;Name&gt;Perth, Perth and Kinross, United Kingdom&lt;/Name&gt;
            &lt;Point&gt;
              &lt;Latitude&gt;56.396049499511719&lt;/Latitude&gt;
              &lt;Longitude&gt;-3.4324100017547607&lt;/Longitude&gt;
            &lt;/Point&gt;
            &lt;BoundingBox&gt;
              &lt;SouthLatitude&gt;56.367079116519164&lt;/SouthLatitude&gt;
              &lt;WestLongitude&gt;-3.5021505233751609&lt;/WestLongitude&gt;
              &lt;NorthLatitude&gt;56.425019882504273&lt;/NorthLatitude&gt;
              &lt;EastLongitude&gt;-3.3626694801343606&lt;/EastLongitude&gt;
            &lt;/BoundingBox&gt;&lt;EntityType&gt;PopulatedPlace&lt;/EntityType&gt;
            &lt;Address&gt;
              &lt;AdminDistrict&gt;Scotland&lt;/AdminDistrict&gt;
              &lt;AdminDistrict2&gt;Perth and Kinross&lt;/AdminDistrict2&gt;
              &lt;CountryRegion&gt;United Kingdom&lt;/CountryRegion&gt;
              &lt;FormattedAddress&gt;Perth, Perth and Kinross, United Kingdom&lt;/FormattedAddress&gt;
              &lt;Locality&gt;Perth&lt;/Locality&gt;
            &lt;/Address&gt;
            &lt;Confidence&gt;High&lt;/Confidence&gt;
            &lt;MatchCode&gt;Good&lt;/MatchCode&gt;
            &lt;GeocodePoint&gt;
              &lt;Latitude&gt;56.396049499511719&lt;/Latitude&gt;
              &lt;Longitude&gt;-3.4324100017547607&lt;/Longitude&gt;
              &lt;CalculationMethod&gt;Rooftop&lt;/CalculationMethod&gt;
              &lt;UsageType&gt;Display&lt;/UsageType&gt;
            &lt;/GeocodePoint&gt;
          &lt;/Location&gt;
        &lt;/Resources&gt;
      &lt;/ResourceSet&gt;
    &lt;/ResourceSets&gt;
  &lt;/Response&gt;
  </code></pre>