Stefan Behnel added the comment:
Here's a complete drop-in replacement.
"""
More specific constraints on which elements to look for and where to look for
them in the tree can be expressed in :ref:`XPath <elementtree-xpath>`.
:meth:`Element.iterfind` iterates over all elements matching such a path
expression. In the following example, it finds all direct <country> children
of *root*. :meth:`Element.find` provides a shortcut to find only the *first*
matching element, in this example the first <rank> child. Once an element is
found, :attr:`Element.text` accesses the element's immediate text content and
:meth:`Element.get` accesses the element's attributes.
::
>>> for country in root.iterfind('country'):
... rank = country.find('rank').text
... name = country.get('name')
... print(name, rank)
...
Liechtenstein 1
Singapore 4
Panama 68
"""
Note that the reviewed doc patch in issue 24079 also hasn't been applied yet.
It would help here.
----------
type: -> enhancement
versions: +Python 2.7, Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24724>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com