Find elements by attribute name and its value using XDocument
<p>Well, using .NET 3.5 and XDocument I am trying to find <code>&lt;table class='imgcr'&gt;</code> element. I created the code below but it crashes, of course, because <code>e.Attribute("class")</code> may be null. So... I have to put null check everywhere? This will double <code>e.Attribute("class")</code>. Not laconic solution at all.</p>

<pre><code>XElement table =
    d.Descendants("table").
    SingleOrDefault(e =&gt; e.Attribute("class").Value == "imgcr");
</code></pre>