E
Emanuele D'Arrigo
Hi everybody, I just tried the following:
Notice the lack of namespace before the attribute "anAttr". I find
this unexpected because as you can see I did set the default namespace
with xmlns="aNamespace" and the elements (rather than the attributes)
are correctly associated with it, i.e.:
<Element {aNamespace}aRoot at 2326cb0>
Is there a way to change this behaviour so that attributes without
namespace are correctly associated with the default namespace, just
like the elements? lxml exhibit the exact same behaviour.
Manu
{'anAttr': '1', '{anotherNamespace}anotherAttr': '2'}import xml.etree.ElementTree as etree
e = etree.fromstring('<aRoot xmlns="aNamespace" xmlns:ans="anotherNamespace"><aChild anAttr="1" ans:anotherAttr="2"/></aRoot>')
e.getchildren()[0].attrib
Notice the lack of namespace before the attribute "anAttr". I find
this unexpected because as you can see I did set the default namespace
with xmlns="aNamespace" and the elements (rather than the attributes)
are correctly associated with it, i.e.:
<Element {aNamespace}aRoot at 2326cb0>
Is there a way to change this behaviour so that attributes without
namespace are correctly associated with the default namespace, just
like the elements? lxml exhibit the exact same behaviour.
Manu