title: How to remove unwanted elements and attributes from XML file using XSLT
body: <p>I have  XML file , I want to copy it as it is , but I want to filter some unwanted elements and attributes , for example the following is the original file :</p>
  
  <pre><code>&lt;root&gt;
  &lt;e1 att="test1" att2="test2"&gt; Value&lt;/e1&gt;
  &lt;e2 att="test1" att2="test2"&gt; Value 2 &lt;inner class='i'&gt;inner&lt;/inner&gt;&lt;/e2&gt;
  &lt;e3 att="test1" att2="test2"&gt; Value 3&lt;/e3&gt;
  
  &lt;/root&gt;
  </code></pre>
  
  <p>After the filtration ( <strong>e3</strong> element and <strong>att2</strong> attribute have been removed ) :</p>
  
  <pre><code>&lt;root&gt;
  &lt;e1 att="test1" &gt; Value&lt;/e1&gt;
  &lt;e2 att="test1" &gt; Value 2 &lt;inner class='i'&gt;inner&lt;/inner&gt;&lt;/e2&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p><strong>Notes:</strong></p>
  
  <ul>
  <li>I prefer to use ( <strong>for-each</strong> element instead of <strong>apply-templates</strong> if that possible )</li>
  <li>I have some problems with <strong>xsl:element</strong> and <strong>xsl:attribute</strong> since I could not write the current node name  </li>
  </ul>
  
  <p>Thanks </p>