It depends on which version you are using. If you have ElementTree 1.3+ (including the standard Python 2.7 library), you can use the base xpath expression as described in the documentation , for example, [@attrib='value'] :
x = ElmentTree(file='testdata.xml') cases = x.findall(".//testcase[@name='VHDL_BUILD_Passthrough'][@classname='TestOne']")
Unfortunately, if you are using an earlier version of ElementTree (1.2, which is included in the standard library for python 2.5 and 2.6), you cannot use this convenience and must filter yourself.
x = ElmentTree(file='testdata.xml') allcases = x12.findall(".//testcase") cases = [c for c in allcases if c.get('classname') == 'TestOne' and c.get('name') == 'VHDL_BUILD_Passthrough']
chmullig
source share