msg277121 - (view) |
Author: py.user (py.user) * |
Date: 2016-09-21 10:27 |
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. |
|
|
msg277187 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2016-09-22 01:37 |
Mostly looks good to me. I left some comments on the code review. |
|
|
msg277194 - (view) |
Author: py.user (py.user) * |
Date: 2016-09-22 06:11 |
> 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.) |
|
|
msg277197 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-09-22 06:26 |
In lxml Element is a factory function, not a class. |
|
|
msg277209 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2016-09-22 08:39 |
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-objects>. |
|
|
msg277211 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-09-22 09:02 |
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. |
|
|
msg277219 - (view) |
Author: py.user (py.user) * |
Date: 2016-09-22 11:31 |
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 "", line 1, in TypeError: must be xml.etree.ElementTree.Element, not lxml.etree._Element >>> |
|
|
msg277255 - (view) |
Author: py.user (py.user) * |
Date: 2016-09-23 08:47 |
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.) |
|
|