robpats added the comment:
Thanks for the pointer. I didn't notice this paragraph.
xml.etree.ElementTree.Element.find currently returns None if XPath expression
is invalid or unsupported. I think it should also return None if position
predicates are not preceded by a tag name. It would be eve
Christian Heimes added the comment:
etree's find method supports a limited subset of XPath,
https://docs.python.org/3/library/xml.etree.elementtree.html#supported-xpath-syntax
. e.find("./*[2]") seems to trigger undefined behavior. The limited XPath
syntax for positions is documented as "pos
New submission from robpats :
Python 3.6.8 / 3.7.9 / 3.8.7
>>> import xml.etree.ElementTree
>>> e = xml.etree.ElementTree.fromstring('>> class="row"/>')
>>> list(e)
[, ,
, ,
, ]
>>> e.find("./div[1]")
>>> e.find("./div[2]")
>>> e.find("./div[3]")
>>> e.find("./hr[1]")
>>> e.find("./hr[2]"