title: How can I use python to remove xml node
body: <p>I want to remove elements from xml files. When I was using ElementTree, I can get all the elements from xml files, but I cannot get the xml statements and annotations.
  So if I use:</p>
  
  <pre><code># get xml nodes
  tree = ElementTree.pares()
  # do filter things ...
  # write to files
  tree.write(file_path)
  </code></pre>
  
  <p>I will miss all the statements and annotations. Is there a way to remove xml elements from *.xml files and keep the annotations, statements or any other things in the files?</p>
  
  <p>For example, the source:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!-- I am annotation --&gt;
  &lt;string name="name"&gt;content&lt;/string&gt;&lt;string left="left"&gt;left things&lt;/string&gt;
  </code></pre>
  
  <p>And my target:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!-- I am annotation --&gt;
  &lt;string left="left"&gt;left things&lt;/string&gt;
  </code></pre>
  
  <p>But when I use tree.write(file_path), it will miss the annotation and statement, become:</p>
  
  <pre><code>&lt;string left="left"&gt;left things&lt;/string&gt;
  </code></pre>