[lxml-dev] Pb with namespaces on attributs
Alain Poirier
alain.poirier at net-ng.com
Wed Nov 14 18:15:50 CET 2007
An attribut of a node, inserted then removed from a tree, can lose its
namespace :
>>> from lxml import etree as ET
>>> parent = ET.Element('parent')
>>> parent.set('{http://foo/bar}x', 'a')
>>> child = ET.SubElement(parent, 'child')
>>> child.set('{http://foo/bar}x', 'b')
>>> print ET.tostring(child), child.nsmap
<child xmlns:ns0="http://foo/bar" ns0:x="b"/> {'ns0': 'http://foo/bar'}
>>> child = parent[0]
>>> parent.clear()
>>> print ET.tostring(child), child.nsmap
<child x="b"/> {}
It happends when the tree already knows the namespace used.
A bug in lxml or in libxml2 (tested with lxml-2.0alpha4 and libxml2 2.6.28 /
2.6.30) ?
More information about the lxml-dev
mailing list