1

I use xml.etree.ElementTree with the function root.findall(xpath) How can I find all roots' children which have 'Status' child with text 'Pass'?

<Root>
    <Some_Element> <!-- I want only this element -->
        <Status>Pass</Status>
    </Some_Element>
    <Some_Element>
        <Status>Fail</Status>
    </Some_Element>
</Root>

Thanks

1 Answer 1

2

Try something like

elements = [x for x in root.findall("Some_Element") if x.find("Status").text == "Pass"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.