title: XSL Transform remove Xml Elements
body: <p>I am stumped. Given an xml doc like:</p>
  
  <pre><code>    &lt;Frag&gt;
          &lt;DirRef Id="BeemzDir"&gt;
              &lt;Com Id="BEED24F05AB78FB588F61D4092654B6D" Guid="{A11AB356-2F45-4157-92EF-ED49F5BE0F70}"&gt;
                  &lt;FileName Id="fil1" KeyPath="yes" Source="My.Exe" /&gt;
              &lt;/Com&gt;
              &lt;Com Id="FFF24F05AB78FB588F61D4092654CCC" Guid="{A11AB356-2F45-4157-92EF-ED49F5BE0F70}"&gt;
                  &lt;FileName Id="fil2" KeyPath="yes" Source="My.Dll" /&gt;
              &lt;/Com&gt; 
            &lt;/DirRef&gt;
  &lt;/Frag&gt;
  &lt;Frag&gt;
          &lt;ComGroup Id="MyGroup"&gt;
              &lt;CompRef Id="BEED24F05AB78FB588F61D4092654B6D" /&gt;
              &lt;CompRef Id="FFF24F05AB78FB588F61D4092654CCC" /&gt;
          &lt;/ComGroup&gt;  
  &lt;/Frag&gt; 
  </code></pre>
  
  <p>I need to use xslt to remove the element that houses the Source="My.Exe". In this case remove element "Com" where its attribute id=BEED24F05AB78FB588F61D4092654B6D.</p>
  
  <p>I have done that. But what I cant do is also remove the "CompRef" element where Id=BEED24F05AB78FB588F61D4092654B6D.</p>
  
  <p>So after transformation I want my xml to look like:</p>
  
  <pre><code>    &lt;Frag&gt;
          &lt;DirRef Id="BeemzDir"&gt;
              &lt;Com Id="FFF24F05AB78FB588F61D4092654CCC" Guid="{A11AB356-2F45-4157-92EF-ED49F5BE0F70}"&gt;
                  &lt;FileName Id="fil2" KeyPath="yes" Source="My.Dll" /&gt;
              &lt;/Com&gt; 
            &lt;/DirRef&gt;
  &lt;/Frag&gt;
  &lt;Frag&gt;
          &lt;ComGroup Id="MyGroup"&gt;
              &lt;CompRef Id="FFF24F05AB78FB588F61D4092654CCC" /&gt;
          &lt;/ComGroup&gt;  
  &lt;/Frag&gt; 
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>Here is some xml that deletes the "FileName" element.</p>
  
  <pre><code>  &lt;xsl:template match="Com/FileName[contains(@Source,'My.Exe')='true']"&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>So that results in:</p>
  
  <pre><code>&lt;Frag&gt;
      &lt;DirRef Id="BeemzDir"&gt;
          &lt;Com Id="BEED24F05AB78FB588F61D4092654B6D" Guid="{A11AB356-2F45-4157-92EF-ED49F5BE0F70}"&gt;
  
          &lt;/Com&gt;
          &lt;Com Id="FFF24F05AB78FB588F61D4092654CCC" Guid="{A11AB356-2F45-4157-92EF-ED49F5BE0F70}"&gt;
              &lt;FileName Id="fil2" KeyPath="yes" Source="My.Dll" /&gt;
          &lt;/Com&gt; 
            &lt;/DirRef&gt;
  &lt;/Frag&gt;
  &lt;Frag&gt;
          &lt;ComGroup Id="MyGroup"&gt;
              &lt;CompRef Id="BEED24F05AB78FB588F61D4092654B6D" /&gt;
              &lt;CompRef Id="FFF24F05AB78FB588F61D4092654CCC" /&gt;
          &lt;/ComGroup&gt;  
  &lt;/Frag&gt;
  </code></pre>
  
  <p>Changing the above xsl that calls an xsl:apply-template doesn nothing, as its stuck in the node its operating in. I dont know how to store the Ids I want to delete and then loop through them.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>There can be more than one node to delete, that is multiple "Com" elements where source="MyExe". Also the Id is autogenerated so will be different each this is run.</p>