Message247738
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. |
|
Date |
User |
Action |
Args |
2015-07-31 06:21:24 | scoder | set | recipients:
+ scoder, rhettinger, eli.bendersky, martin.panter, Eric S |
2015-07-31 06:21:24 | scoder | set | messageid: <1438323684.11.0.742091747049.issue24724@psf.upfronthosting.co.za> |
2015-07-31 06:21:24 | scoder | link | issue24724 messages |
2015-07-31 06:21:23 | scoder | create | |
|