Quantcast
Channel: Find occurrence using multiple attributes in ElementTree/Python - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Santa for Find occurrence using multiple attributes in ElementTree/Python

$
0
0

You'll have to iterate through the <testcase /> elements that you have, like so:

from xml.etree import cElementTree as ET# assume xmlstr contains the xml string as above# (after being fixed and validated)testsuites = ET.fromstring(xmlstr)testsuite = testsuites.find('testsuite')for testcase in testsuite.findall('testcase'):    if testcase.get('name') == 'VHDL_BUILD_Passthrough':        # do what you will with `testcase`, now it is the element        # with the sought-after attribute        print repr(testcase)

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>