[issue23423] XPath Support in ElementTree doc omission
New submission from Mark Baker: The list of XPath supported features in section 20.5.2.2. "Supported XPath syntax" on page https://docs.python.org/3.4/library/xml.etree.elementtree.html does not list the use of a predicate based on an element value (it only list predicates based on an attribute value. However, testing in 3.4 shows that a predicate based on an element value also works.
import xml.etree.ElementTree as etree x = '<foo><bar><baz y="bang">bing</baz></bar></foo>' y = etree.XML(x)
# Find by attribute value
z = y.find('bar/baz[@y="bang"]') print(z) <Element 'baz' at 0x0000000003300368>
# Find by element value
z = y.find('bar/[baz="bing"]') print(z) <Element 'bar' at 0x000000000334AD18>
# Find fails with incorrect element value
z = y.find('bar/[baz="bong"]') z print(z) None
Below the line that says: [tag] Selects all elements that have a child named tag. Only immediate children are supported. It should say something like: [tag="value"] Selects all elements that have a child named tag with the given value. Only immediate children are supported. ---------- assignee: docs@python components: Documentation messages: 235627 nosy: docs@python, mbakeranalecta priority: normal severity: normal status: open title: XPath Support in ElementTree doc omission type: enhancement versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue23423> _______________________________________
Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +scoder _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue23423> _______________________________________
Stefan Behnel <stefan_ml@behnel.de> added the comment: Already fixed in later versions of the documentation: https://docs.python.org/3/library/xml.etree.elementtree.html#supported-xpath... Note that Py3.4 is no longer maintained. ---------- resolution: -> out of date stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue23423> _______________________________________
participants (3)
-
Karthikeyan Singaravelan
-
Mark Baker
-
Stefan Behnel