Author scoder
Recipients Eric S, eli.bendersky, martin.panter, rhettinger, scoder
Date 2015-07-31.06:21:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438323684.11.0.742091747049.issue24724@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-07-31 06:21:24scodersetrecipients: + scoder, rhettinger, eli.bendersky, martin.panter, Eric S
2015-07-31 06:21:24scodersetmessageid: <1438323684.11.0.742091747049.issue24724@psf.upfronthosting.co.za>
2015-07-31 06:21:24scoderlinkissue24724 messages
2015-07-31 06:21:23scodercreate