title: Get xml node value as string C#
body: <p>I've been trying to pull the value of the XML node into a string.  Here is what the XML looks like:</p>
  
  <pre><code>&lt;currentvin value="1FTWW31R08EB18119" /&gt; 
  </code></pre>
  
  <p>I can't seem to figure out how to grab that value.  I didn't write this XML, by the way.  So far I have tried several approaches, including the following:</p>
  
  <pre><code>    public void xmlParse(string filePath)
      {
          XmlDocument xml = new XmlDocument();
          xml.Load(filePath);
          XmlNode currentVin = xml.SelectSingleNode("/currentvin");
          string xmlVin = currentVin.Value;
          Console.WriteLine(xmlVin);          
      }
  </code></pre>
  
  <p>Which doesn't work.  I then tried:</p>
  
  <pre><code>    public void xmlParse(string filePath)
      {
          XmlDocument xml = new XmlDocument();
          xml.Load(filePath);
          string xmlVin = xml.SelectSingleNode("/currentvin").Value;
          Console.WriteLine(xmlVin);
  
      }
  </code></pre>
  
  <p>But that doesn't work either.  I am getting a null reference exception stating that Object reference not set to an instance of an object.  Any ideas?</p>