Martin Panter added the comment:

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>]

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24724>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to