Blog Archive for June 17, 2010

Using ElementTree in Python

June 17, 2010

This page contains some code that is useful for working with ElementTree in Python.

Parse an XML File

This code parses an XML file from disk into an ElementTree instance

from xml.etree.ElementTree import ElementTree

lDocument = ElementTree()
lDocument.parse(pFilepath)
lRoot = lDocument.getroot() …