import drill
doc = drill.parse(path_or_url_or_string)
# Drill down to a specific element.
print unicode(doc.book.title)
# Iterate through all "title" tags in the document.
for t in doc.iter('title'):
print t.attrs, t.data
# Find all "bar" nodes with a "baz" child and a "foo" parent.
q = doc.find('//foo/bar[baz]')
# Easily access the first and last elements of matching results.
print q.first(), q.last()
# Iterate over results.
for e in q:
do_something(e)
# Parse only elements matching some path
for e in drill.iterparse(filelike, xpath='root/*/something'):
print e.tagname, e.data