Hi everybody, I just tried the following:

>>> 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
{'anAttr': '1', '{anotherNamespace}anotherAttr': '2'}

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.:

>>> 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to