title: How to delete specific nodes from an XElement?
body: <p>I have created a XElement with node which has XML as below. </p>
  
  <p>I want to remove all the "<em>Rule</em>" nodes if they contain "<em>conditions</em>" node. </p>
  
  <p>I create a for loop as below but it does not delete my nodes</p>
  
  <pre><code>foreach (XElement xx in xRelation.Elements())
  {
    if (xx.Element("Conditions") != null)
    {
      xx.Remove();
    }
  }
  </code></pre>
  
  <p><strong>Sample:</strong></p>
  
  <pre><code>&lt;Rules effectNode="2" attribute="ability" iteration="1"&gt;
      &lt;Rule cause="Cause1" effect="I"&gt;
        &lt;Conditions&gt;
          &lt;Condition node="1" type="Internal" /&gt;
        &lt;/Conditions&gt;
      &lt;/Rule&gt;
      &lt;Rule cause="cause2" effect="I"&gt;
        &lt;Conditions&gt;
          &lt;Condition node="1" type="External" /&gt;
        &lt;/Conditions&gt;
      &lt;/Rule&gt;
  &lt;/Rules&gt;
  </code></pre>
  
  <p>How can I remove all the "<em>Rule</em>" nodes if they contain "<em>conditions</em>" node?</p>