Create SVG / XML document without ns0 namespace using Python ElementTree [duplicate] Create SVG / XML document without ns0 namespace using Python ElementTree [duplicate] python python

Create SVG / XML document without ns0 namespace using Python ElementTree [duplicate]


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.


Here's how I do it with lxml.

from lxml import etreesvg_tree = etree.fromstring(svg_str, parser=etree.XMLParser())etree.tostring(svg_tree)

Used sample code from here:lxml-removing-xml-tags-when-parsing