[issue28234] In xml.etree.ElementTree docs there are many absent Element class links
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
New submission from py.user: https://docs.python.org/3/library/xml.etree.elementtree.html#reference 1. Comment 2. iselement() 3. ProcessingInstruction 4. SubElement 5. Element.find() 6. ElementTree._setroot() 7. TreeBuilder Applied a patch to the issue that adds Element class links. ---------- assignee: docs@python components: Documentation, Library (Lib), XML files: element-link.diff keywords: patch messages: 277121 nosy: docs@python, py.user priority: normal severity: normal status: open title: In xml.etree.ElementTree docs there are many absent Element class links type: behavior versions: Python 3.6 Added file: http://bugs.python.org/file44775/element-link.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Changes by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- nosy: +eli.bendersky, scoder stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Martin Panter added the comment: Mostly looks good to me. I left some comments on the code review. ---------- nosy: +martin.panter versions: +Python 2.7, Python 3.5, Python 3.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
py.user added the comment:
I left some comments on the code review. Left an answer on a comment. (ISTM, email notification doesn't work there, I didn't get email.)
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Serhiy Storchaka added the comment: In lxml Element is a factory function, not a class. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Martin Panter added the comment: Serhiy, what’s the relevance? In the built-in Element Tree package, it is a class: <https://docs.python.org/3.5/library/xml.etree.elementtree.html#element-objec...>. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Serhiy Storchaka added the comment: The built-in ElementTree package is derived from lxml.etree. I suppose that the documentation is inherited from lxml.etree. The built-in ElementTree package supports duck typing. The element object is not always an instance of the Element class. iselement() is not equal to isinstance(e, Element), it just tests the existence of the tag attribute. Many ElementTree functions have fast path for Element, but work with duck typed classes too. I believe that in particular you can mix Python and C implementations of Element and lxml.etree elements in one tree. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
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@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
py.user added the comment: Added a reply to the patch about SubElement(). (Realy email notification doesn't work in review. I left a message while publication, and it didn't come.) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue28234> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- pull_requests: +9156 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue28234> _______________________________________
participants (3)
-
Martin Panter
-
py.user
-
Serhiy Storchaka