Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xml.etree.ElementTree中的python xpath_Python_Xpath - Fatal编程技术网

xml.etree.ElementTree中的python xpath

xml.etree.ElementTree中的python xpath,python,xpath,Python,Xpath,我将xml.etree.ElementTree与函数root.findall(xpath) 我如何找到所有具有“Status”child且文本为“Pass”的根“child” <Root> <Some_Element> <!-- I want only this element --> <Status>Pass</Status> </Some_Element> <Some_Ele

我将
xml.etree.ElementTree
与函数
root.findall(xpath)
我如何找到所有具有“Status”child且文本为“Pass”的根“child”

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

通过
失败
谢谢

试试类似的东西

elements = [x for x in root.findall("Some_Element") if x.find("Status").text == "Pass"]