Remove ns0 from XML
<p>I have an XML file where I would like to edit certain attributes. I am able to properly edit the attributes but when I write the changes to the file, the tags have a strange &quot;ns0&quot; added onto them. How can I get rid of this? This is what I have tried and have been unsuccessful. I am working in Python and using lxml.</p>
<pre><code>import xml.etree.ElementTree as ET
from xml.etree import ElementTree as etree
from lxml import etree, objectify
frag_xml_tree = ET.parse(xml_name)
frag_root = frag_xml_tree.getroot()

for e in frag_root: 
    for elem in frag_root.iter(e):
        elem.attrib[frag_param_name] = update_val
    etree.register_namespace(&quot;&quot;, &quot;http://www.w3.org/2001&quot;)
    frag_xml_tree.write(xml_name)
</code></pre>
<p>However, when I do this, I only get the error <code>Invalid tag name u''</code>. I thought this error came up if the xml tags started with digits but that is not the case with my xml. I am really stuck on how to proceed. Thanks</p>