The quickest way to convert an XML file into an ElementTree is to use this function:
etree.parse ( source )
where
is the name of the file, or a sourcefile object
containing the XML. If the file is well-formed, the
function returns an ElementTree instance.
Exceptions raised include:
IOError
The file is nonexistent or not readable.
etree.XMLSyntaxError
The file is readable, but does not contain
well-formed XML. The returned exception contains
an .error_log attribute that you can
print to see where the error occurred. For an
example of the display of the error_log, see Section 6.3, “The ElementTree() constructor”.