title: Unable to remove element/node using ElementTree
body: <p>I have an issue with ElementTree that I can't quite figure out.  I've read all their documentation as well as all the information I could find on this forum.  I have a couple elements/nodes that I am trying to remove using ElementTree.  I don't get any errors with the following code, but when I look at the output file I wrote the changes to, the elements/nodes that I expected to be removed are still there.  I have a document that looks like this:</p>
  
  <pre><code>&lt;data&gt;
    &lt;config&gt;
      &lt;script filename="test1.txt"&gt;&lt;/script&gt;
      &lt;documentation filename="test2.txt"&gt;&lt;/script&gt;
    &lt;/config&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>My code looks as follows:</p>
  
  <pre><code>import xml.etree.ElementTree as ElementTree    
  xmlTree = ElementTree.parse(os.path.join(sourcePath, "test.xml"))
  xmlRoot = xmlTree.getroot()
  for doc in xmlRoot.findall('documentation'):
       xmlRoot.remove(doc)
  
  xmlTree.write(os.path.join(sourcePath, "testTWO.xml"))
  </code></pre>
  
  <p>The result is I get the following document:</p>
  
  <pre><code>&lt;data&gt;
    &lt;config&gt;
      &lt;script filename="test1.txt" /&gt;
      &lt;documentation filename="test2.txt" /&gt;
    &lt;/config&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>What I need is something more like this.  I am not stuck using ElementTree. If there is a better solution with lxml or some other library, I am all ears.  I know ElementTree can be a little bit of a pain at times.</p>
  
  <pre><code>&lt;data&gt;
    &lt;config&gt;
    &lt;/config&gt;
  &lt;/data&gt;
  </code></pre>