title: Getting the innerText
body: <p>I have an xml file like this:</p>
  
  <pre><code>&lt;locations&gt;
      &lt;location country="UK"&gt;
          &lt;name&gt;London&lt;/name&gt;
          &lt;class&gt;Silver&lt;/class&gt;
      &lt;/location&gt;
      &lt;location country="Germany"&gt;
          &lt;name&gt;Berlin II&lt;/name&gt;
          &lt;class&gt;Bronze&lt;/class&gt;
      &lt;/location&gt;
  &lt;/locations&gt;
  </code></pre>
  
  <p>When opening a page I deduct a value "currentCountry" from the URL. Now I want to use that value to search the XML file for the corresponding <code>location</code> entry and put the innerHtml value of its child nodes into variable. This is my current code, which is not working so far:</p>
  
  <pre><code>string currentCountry = "Germany" //For testing purposes
  string currentName = "";
  string currentClass = "";
  
  XmlDocument doc = new XmlDocument();
  doc.Load("C:\\IIS\\Web\\Content\\locations.xml");
  
  XmlNodeList xnList = doc.SelectNodes("/locations/location[@country='" + currentCountry + "']");
  foreach (XmlNode xn in xnList)
  {
      currentName = xn.SelectSingleNode("/name").InnerText;
      currentClass = xn.SelectSingleNode("/class").InnerText;
  }
  </code></pre>
  
  <p>I get the error <code>System.NullReferenceException: Object reference not set to an instance of an object.</code> pointing to the first line inside the <code>foreach</code> loop.</p>
  
  <p>Can anyone point me in the right direction please?</p>