Is it possible to use XPath Query in Python when processing XML. I am using minidom which does not support this. Is there any other module for this?
http://docs.python.org/library/xml.etree.elementtree.html
etree supports XPath queries, just like lxml.
etree is included in the standard library, but lxml is faster.
My favorite Python XML processing library is lxml , which, since it is a wrapper around libxml2, also supports full XPath.
There is also 4Suite , which is a cleaner Python solution.
ElementTree is included. Under 2.6 and below, its xpath is rather weak, but in 2.7 it has improved significantly :
import xml.etree.ElementTree as et root = et.parse(filename) result = '' # How to make decisions based on attributes even in 2.6 for e in root.findall('.//child/grandchild'): if e.attrib.get('name') == 'foo': result = e.text break