ElementTree - findall to recursively select all child elements

If you aren't afraid of a little XPath, you can use the // syntax that means find any descendant node:

import xml.etree.ElementTree as ET
root = ET.parse("h.xml")
print(root.findall('.//saybye'))

Full XPath isn't supported, but here's the list of what is: https://docs.python.org/2/library/xml.etree.elementtree.html#supported-xpath-syntax


From version 2.7 on, you can use xml.etree.ElementTree.Element.iter:

import xml.etree.ElementTree as ET
root = ET.parse("h.xml")
print root.iter('saybye')

See 19.7. xml.etree.ElementTree — The ElementTree XML API