[docs] [issue28234] In xml.etree.ElementTree docs there are many absent Element class links

py.user report at bugs.python.org
Thu Sep 22 07:31:25 EDT 2016


py.user added the comment:

Serhiy Storchaka wrote:
> I believe that in particular you can mix Python and
> C implementations of Element and lxml.etree elements in one tree.


The xml.etree.ElementTree.ElementTree() can accept lxml.etree.Element() as a node, but node in node is impossible.

>>> import xml.etree.ElementTree as etree_xml
>>> import lxml.etree as etree_lxml
>>> 
>>> elem1 = etree_xml.Element('a')
>>> elem2 = etree_lxml.Element('b')
>>> elem1.append(elem2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be xml.etree.ElementTree.Element, not lxml.etree._Element
>>>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28234>
_______________________________________


More information about the docs mailing list