Author martin.panter
Recipients Eric S, eli.bendersky, martin.panter, rhettinger, scoder
Date 2015-07-31.23:11:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438384282.48.0.948773180582.issue24724@psf.upfronthosting.co.za>
In-reply-to
Content
Eric: Calling findall("country") does _not_ return grandchidren nor further descendants. Also, your pseudocode calling findall() with no arguments does not work, so I am left wondering where you got the wrong impression about grandchildren. The usual way to get a list of direct children is to call list(parent):

>>> root = XML('''<data><country name="Leichtenstein">
...         <country name="Singapore"><country name="Panama"/></country>
...     </country></data>''')
>>> root.findall()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Required argument 'path' (pos 1) not found
>>> list(root)  # List of direct children
[<Element 'country' at 0xb6ebe324>]
>>> root.findall("country")  # List of direct <country> children
[<Element 'country' at 0xb6ebe324>]
>>> root.findall(".//country")  # List of all <country> descendants
[<Element 'country' at 0xb6ebe324>, <Element 'country' at 0xb6ebe284>, <Element 'country' at 0xb6ebe0cc>]
History
Date User Action Args
2015-07-31 23:11:22martin.pantersetrecipients: + martin.panter, rhettinger, scoder, eli.bendersky, Eric S
2015-07-31 23:11:22martin.pantersetmessageid: <1438384282.48.0.948773180582.issue24724@psf.upfronthosting.co.za>
2015-07-31 23:11:22martin.panterlinkissue24724 messages
2015-07-31 23:11:22martin.pantercreate