title: write the whole content of xml node without adding "xmlns="
body: <p>From my xml file, I want to write each child node to a separate file. I use <code>xml.etree.ElementTree.tostring(child_node)</code> for this. I already found that I should use <code>.register_namespace()</code> to avoid adding "ns0:" to every tag. But I still have "xmlns=" attribute added to every node I am saving:</p>
  
  <p>Here is sample xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;kml xmlns="http://earth.google.com/kml/2.1"&gt;
  &lt;Document&gt;
   &lt;name&gt;ref.kml&lt;/name&gt;
   &lt;Style id="normalState"&gt;
      &lt;IconStyle&gt;&lt;scale&gt;1.0&lt;/scale&gt;&lt;Icon&gt;&lt;href&gt;yt.png&lt;/href&gt;&lt;/Icon&gt;&lt;/IconStyle&gt;
      &lt;BalloonStyle&gt;&lt;text&gt;&lt;![CDATA[$[description]]]&gt;&lt;/text&gt;&lt;/BalloonStyle&gt;    
   &lt;/Style&gt;
  &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import xml.etree.ElementTree as ET
  
  str_ns_url = 'http://earth.google.com/kml/2.1'
  ET.register_namespace('', str_ns_url)
  
  kml_file = ET.parse('my.kml')
  kml_doc = kml_file.getroot()[0]
  
  ndx = 0
  for child in kml_doc:
      ndx+=1
      f = open('node'+str(ndx)+'.txt','w')
      f.write(ET.tostring(child))
      f.close()
  </code></pre>
  
  <p>And this is the output for the first node (<code>&lt;name&gt;</code>):</p>
  
  <pre><code>&lt;name xmlns="http://earth.google.com/kml/2.1"&gt;ref.kml&lt;/name&gt;
  </code></pre>
  
  <p>As you see, <code>xmlns=</code> was added to the tag. So far I only found <a href="https://stackoverflow.com/questions/7004215/">this SO post</a> which basically suggests manual removal of that substring after <code>.tostring()</code>. Is there any better solution? Maybe I should use something else instead of <code>ElementTree.tostring()</code>?</p>