title: LINQ TO XML get node based on multiple conditions
body: <p>How can i get the node "FieldName" based on xID &amp;&amp; dID through LINQ TO XML. 
  Note : dID may or may not exist.
  What i had tried so far is printed below. 
  However my code does not handle the condition when dID doesn not exist</p>
  
  <pre><code>&lt;Configuration&gt;
          &lt;Contract xID="2"&gt;
              &lt;Document dID="227"&gt;
                  &lt;FieldName name="AAAA"/&gt;
                  &lt;FieldName name="BBBB"/&gt;
              &lt;/Document&gt;
          &lt;/Contract&gt;
          &lt;Contract xID="5"&gt;
  
                  &lt;FieldName nam`enter code here`e="CCCC"/&gt;
                  &lt;FieldName name="DDDD"/&gt;
  
          &lt;/Contract&gt;
      &lt;/Configuration&gt;
  </code></pre>
  
  <p>What i had tried so far is printed below. 
  However my code does not handle the condition when dID doesn not exist</p>
  
  <pre><code>    XDocument xmlDoc = XDocument.Load("../../FieldConfiguration.xml");
  
      var fieldNames = (from n in xmlDoc.Descendants("Contract")
                        where (int)n.Attribute("xID") == 5 &amp;&amp;
                              (int)n.Element("Document").Attribute("dID") == 227
                        from f in n.Element("Document").Elements()
                        select (string) f.Attribute("name")).ToList();
  
      foreach (string name in fieldNames)
      {
          Console.WriteLine("Site: " + name);
      }
  </code></pre>