title: How query xml element using linq whether or not the element is existed C#
body: <p>I am trying to loop through several XML files from my local machine with the same format but some files have the missing element which is the images. when the loop reaches a file with the missing element the program crashes on select new.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;node&gt;
      &lt;id&gt;1663&lt;/vid&gt;
  
      &lt;title&gt;My Title&lt;/title&gt;
  
      &lt;body&gt;
      &lt;und keys="1"&gt;
          &lt;n0&gt;
              &lt;value&gt;123 Street&lt;/value&gt;
              &lt;summary&gt;&lt;/summary&gt;
              &lt;format type="NULL"&gt;&lt;/format&gt;
              &lt;safe_value&gt;123 Street&lt;/safe_value&gt;
              &lt;safe_summary&gt;&lt;/safe_summary&gt;
          &lt;/n0&gt;
      &lt;/und&gt;
      &lt;/body&gt;
     &lt;field keys="1"&gt;&lt;/field&gt;
     &lt;image&gt;
         &lt;und keys="1"&gt;
              &lt;i0&gt;     
                  &lt;uri&gt;https://uei.jpg&lt;/uri&gt;     
              &lt;/i0&gt;
              &lt;i1&gt;
                  &lt;uri&gt;https://myurl.jpg&lt;/uri&gt;     
              &lt;/i1&gt;
          &lt;/und&gt;
      &lt;/image&gt;
  &lt;/node&gt;
  </code></pre>
  
  <p>Linq C# (WPF) APP:</p>
  
  <pre><code>XDocument document = XDocument.Load(file);
  var nodes = from b in document.Descendants("node")
              let imgs = b.Element("image")
              select new
              {
                  ID = (string)b.Element("id").Value,
                  Title = (string)b.Element("title").Value,
                  StreetName = (string)b.Element("body").Element("und").Element("n0").Element("value").Value,
                  Images = imgs.Descendants("und").ToList()
              };
  </code></pre>