title: How do I extract child nodes from XML file using XPath when both child nodes must exist?
body: <p>I am trying to extract certain values from an xml document. In the example below, I want to store the values stored in the 'c' and 'd' nodes in a list, but only where the 'b' node contains both 'c' AND 'd'. The code I have so far loops through all of the 'b' nodes, but I am uncertain what to put in the while loop, or if this is the best approach.</p>
  
  <pre><code>XmlDocument attrsXML = new XmlDocument();
  attrsXML.LoadXml(dbReader["SampleXml"].ToString());
  
  XPathNavigator nav = attrsXML.CreateNavigator();
  
  XPathNodeIterator attribNodes = nav.Select("/a/b");
  
  while (attribNodes.MoveNext())
  {
      // What do I need to put here in order to extract the 'c' and 'd' nodes?
      // Any other nodes can be ignored (such as 'e' above). I am only interested
      // when 'b' contains both 'c' AND 'd'.
  }
  </code></pre>
  
  <p>Where 'SampleXml' loaded from the database is:</p>
  
  <pre><code>&lt;a&gt;
      &lt;b&gt;
          &lt;c&gt;Extract this&lt;/c&gt;
          &lt;d&gt;And this&lt;/d&gt;
          &lt;e&gt;not this&lt;/e&gt;
      &lt;/b&gt;
      &lt;b&gt;
          &lt;c&gt;not this&lt;/c&gt;
          &lt;e&gt;not this&lt;/e&gt;
      &lt;/b&gt;
      &lt;b&gt;
          &lt;c&gt;Extract this&lt;/c&gt;
          &lt;d&gt;And this&lt;/d&gt;
      &lt;/b&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>Any help appreciated.</p>