title: C# check an element exists while using LINQ to XML
body: <p>OK, bit of a random question, but the best way to do this is to just add the code, you'll be able to see what I mean straight away:</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;customers&gt;
    &lt;customer&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;name&gt;Blah-face&lt;/name&gt;
      &lt;Type&gt;1&lt;/Type&gt;
    &lt;/customer&gt;
    &lt;customer&gt;
      &lt;id&gt;2&lt;/id&gt;
      &lt;name&gt;Blah-face-2&lt;/name&gt;
      &lt;Type&gt;2&lt;/Type&gt;
    &lt;/customer&gt;
    &lt;customer&gt;
      &lt;id&gt;3&lt;/id&gt;
      &lt;name&gt;Blah-face-3&lt;/name&gt;
      &lt;Type&gt;1&lt;/Type&gt;
      &lt;SuperType&gt;1&lt;/SuperType&gt;
    &lt;/customer&gt;
  &lt;/customers&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>XDocument linquee = XDocument.Load(path);
  
  var superType = (from c in linquee.Descendants("customer")
                   where (c.Element("SuperType").Value == "1")
                   select c).ToList();
  </code></pre>
  
  <p>This comes up with a null error - would I need to add the "SuperType" element to each customer before it with a null value, or is there a workaround that would mean I don't have to do that?</p>
  
  <p>Cheers!</p>