Next / Previous / Contents / Shipman's homepage

8.5. ElementTree.getroot(): Find the root element

To obtain the root element of a document contained in an ElementTree instance ET, use this method call:

ET.getroot()

The return value will normally be the Element instance at the root of the tree. However, if you have created your ElementTree instance without specifying either a root element or an input file, this method will return None.