There is any solution to add namespaces without prefix(i mean these ns0, ns1) which working on all the etree implementations or there are working solutions for each one?
For now I have solutions for:
- lxml – nsmap argument of Element
- (c)ElementTree(python 2.6+) – register namespace method with empty string as a prefix
The problem is (c)ElementTree in python 2.5, I know there is _namespace_map attribute but setting it to empty string creating invalid XML, setting it to None adding default ns0 etc. namespaces, is there any working solution?
I guess
Element('foo', {'xmlns': 'http://my_namespace_url.org/my_ns'})
is a bad idea?
Thanks for help
I have just work around for you.
Define your own prefix:
And then, replace/remove the prefix on the output:
Probably, there is better solution.