title: Stop ElementTree removing namespace from elements
body: <p>Some of my elements in the xml file I am parsing have their own xmlns attribute, but whenever I parse and write the file back, the xmlns are removed and instead I get a ns3: prefix and a new namespace is added at the top.</p>
  
  <p>The head of the XML file I'm reading:</p>
  
  <pre><code>&lt;oval_definitions xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#windows http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/windows-definitions-schema.xsd"&gt;
  </code></pre>
  
  <p>The head of the output I get:</p>
  
  <pre><code>&lt;oval_definitions xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns3="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#windows http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/windows-definitions-schema.xsd"&gt;
  </code></pre>
  
  <p>My namespace declarations:</p>
  
  <pre><code>ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5")
  ET.register_namespace('oval', "http://oval.mitre.org/XMLSchema/oval-common- 5")
  ET.register_namespace('xsi', "http://www.w3.org/2001/XMLSchema-instance")
  ET.register_namespace('xsi:schemaLocation', "http://oval.mitre.org/XMLSchema/oval-common-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#windows http://oval.mitre.org/language/download/schema/version5.8/ovaldefinition/complete/windows-definitions-schema.xsd")
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>&lt;registry_state xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" id="oval:mil.disa.fso.windows:ste:397100" version="2" comment="Reg_Dword type and value equals 0"&gt;
  </code></pre>
  
  <p>What I'm getting now:</p>
  
  <pre><code>&lt;ns3:registry_state comment="Reg_Dword type and value equals 0" id="oval:mil.disa.fso.windows:ste:397100" version="2"&gt;
  </code></pre>
  
  <p>How can I get the xmlns= attribute back into my elements and out of the head of the document?</p>