19.7. xml.etree.ElementTree — The ElementTree XML API ... | Python read XML file
TheElement[1]typeisaflexiblecontainerobject,designedtostorehierarchicaldatastructuresinmemory.Thetypecanbedescribedasacrossbetweenalistandadictionary.Tocreateanelementinstance,usetheElement[2]constructorortheSubElement()[3]factoryfunction.TheElementTree[4]classcanbeusedtowrapanelementstructure,andconvertitfromandtoXML.ACimplementationofthisAPIisavailableasxml.etree.cElementTree.Seehttp://effbot.org/zone/element-index.htm[5]fortutorialsandlinkstootherdocs.FredrikLundh’spageisalsothelocationof...
The Element[1] type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary.
To create an element instance, use the Element[2] constructor or the SubElement()[3] factory function.
The ElementTree[4] class can be used to wrap an element structure, and convert it from and to XML.
A C implementation of this API is available as xml.etree.cElementTree.
See http://effbot.org/zone/element-index.htm[5] for tutorials and links to other docs. Fredrik Lundh’s page is also the location of the development version of the xml.etree.ElementTree.
19.7.1. TutorialThis is a short tutorial for using xml.etree.ElementTree[6] (ET in short). The goal is to demonstrate some of the building blocks and basic concepts of the module.
19.7.1.1. XML tree and elementsXML is an inherently hierarchical data format, and the most natural way to represent it is with a tree....