2

Python(2.7.5) ElementTree を使用して、複数の検索条件で xml ファイルから要素を抽出したいと考えています。xml は次のようになります。

   <src name="BdsBoot.c">
        <fn name="XXXXX" fn_cov="0" fn_total="1" cd_cov="0" cd_total="4">
           <probe line="113" kind="condition" event="full"/>
           <probe line="122" column="10" kind="condition" event="none" />
           <probe line="124" column="9" kind="condition" event="full" />
        </fn>
   </src>

kind="condition" および event="full" のプローブ要素が必要です

私が試してみました

root.findall(".//probe[@kind='condition' and @event='full']") —— error
root.findall(".//probe[@kind='condition'] and .//probe[@event='full']") —— nothing

ここで簡単な紹介を読みましたが、現在、elementtree は and 演算子をサポートしていないようですか?

この目標を達成する方法はありますか?

4

1 に答える 1