title: How to use XPath with XElement or LINQ?
body: <p>Consider the following XML:</p>
  
  <pre><code>&lt;response&gt;
    &lt;status_code&gt;200&lt;/status_code&gt;
    &lt;status_txt&gt;OK&lt;/status_txt&gt;
    &lt;data&gt;
      &lt;url&gt;http://bit.ly/b47LVi&lt;/url&gt;
      &lt;hash&gt;b47LVi&lt;/hash&gt;
      &lt;global_hash&gt;9EJa3m&lt;/global_hash&gt;
      &lt;long_url&gt;http://www.tumblr.com/docs/en/api#api_write&lt;/long_url&gt;
      &lt;new_hash&gt;0&lt;/new_hash&gt;
    &lt;/data&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>I'm looking for a really short way to get just the value of the <code>&lt;hash&gt;</code> element. I tried:</p>
  
  <pre><code>var hash = xml.Element("hash").Value;
  </code></pre>
  
  <p>But that's not working. Is it possible to provide an XPath query to an <code>XElement</code>? I can do it with the older <code>System.Xml</code> framework, doing something like:</p>
  
  <pre><code>xml.Node("/response/data/hash").Value
  </code></pre>
  
  <p>Is there something like this in a LINQ namespace?</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>After monkeying around with this some more I found a way to do what I'm trying to do:</p>
  
  <pre><code>var hash = xml.Descendants("hash").FirstOrDefault().Value;
  </code></pre>
  
  <p>I'd still be interested to see if anyone has a better solution?</p>