I'm building an SVG document with ElementTree in Python 2.7. Here is the code:
from xml.etree import ElementTree as etree
root = etree.XML('')
root.append(etree.Element("path"))
root[0].set("d", "M1 1 L2 2 Z")
print etree.tostring(root, encoding='iso-8859-1')
This generates the output:
This does not parse as valid SVG.
How can I remove the ns0 namespace?
解决方案
I just figured it out and I can't delete the question so here it is:
etree.register_namespace("","http://www.w3.org/2000/svg")
I think this only works as of Python 2.7 though.