title: Is there a way to remove xml header added by ElementTree.tostring method?
body: <p>Before writing processed data to xml I do some formatting so it would all look nice in the result xml document.</p>
  
  <pre><code>import xml.etree.ElementTree as et
  import xml.dom.minidom as mdom
  (...)
  
  for i in range(10):
      root = et.Element("main")
      (...)
  
      ugly_xml = et.tostring(root, 'utf-8', method='xml')
      parsed_xml = mdom.parseString(ugly_xml)
      nice_xml = parsed_xml.toprettyxml(indent=" " * 3)
      with open('test.xml', 'a') as f:
           f.write(nice_xml)
  </code></pre>
  
  <p>However the result file obviously has duplicate xml headers.</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  (...)
  &lt;?xml version="1.0" ?&gt;
  (...)
  &lt;?xml version="1.0" ?&gt;
  </code></pre>
  
  <p>Is there a way not to print xml header with tostring method? The docs didn't provide any info except that I can just try different types like 'html' or 'text'.</p>