diff -r 3191da5c3726 Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst Tue Jul 20 01:17:22 2010 +0200 +++ b/Doc/library/xml.etree.elementtree.rst Mon Jul 19 22:28:55 2010 -0500 @@ -412,6 +412,38 @@ getroot().findall(match). *match* may be a tag name or path. Returns a list containing all matching elements, in document order. + Example of some of the allowed paths for find and findall: + + >>> import xml.etree.ElementTree + >>> exampleXml = """ + ... + ... + ... + ... 2.7 + ... 3.2 + ... 3.3 + ... + ... + ... + ... + ... 2.5 + ... + ... + ... + ... """ + >>> tree = xml.etree.ElementTree.fromstring(exampleXml) + >>> vs = tree.findall("*//version") # Finds all occurences of version tags + >>> len(vs) + 4 + >>> tree.findall("cpython/*/version") # Finds all occurences of version tags that are grandchildren of cpython + [, , ] + >>> tree.findall("cpython/versions/version[1]") # Finds the second occurence of version tag under cpython + [] + >>> tree.findall("*//version[@stable]") # Finds all occurrences of version tags with stable attributes + [, ] + >>> tree.findall("*//version[@stable='yes']") # Finds all occurrences of version tags with stable attributes with values of yes + [] + .. method:: findtext(match, default=None)