title: Search all child nodes of XML node for a value and remove the grandparent node
body: <p>Trying to use</p>
  
  <pre><code>exportDoc.Root.Elements("string").Where(node =&gt; !(node.Element("product").HasElements) || node.Element("product").Element("type").Value != product).Remove();
  </code></pre>
  
  <p>to remove the nodes in my XML document where the <code>product</code> string I'm searching for doesn't occur. Here is a sample of my XML structure:</p>
  
  <pre><code>&lt;root&gt;
     &lt;string id = "Hithere"&gt;
        &lt;product&gt;
           &lt;type&gt;orange&lt;/type&gt;
           &lt;type&gt;yellow&lt;/type&gt;
           &lt;type&gt;green&lt;/type&gt;
        &lt;product&gt;
        &lt;element2/&gt;
        &lt;element3/&gt;
      &lt;/string&gt;
      &lt;string id ="..."&gt;
       ...
       ... 
  &lt;/root&gt;
  </code></pre>
  
  <p>So I need to look under the <code>product</code> element of each <code>string</code> element AND at each of the <code>type</code> elements therein to see if the value of string <code>product</code> (input to the method where this is contained) occurs. At present, it looks like my code only removes the node if the <code>product</code> string I'm searching for matches the value of just the first <code>type</code> element.</p>
  
  <p>The whole point is to remove all string nodes from this xdoc that don't have the product I'm looking for listed under their <code>product</code> element.</p>