xpath結果を評価するために使用されるすべてのコンテキストノードを取得することは可能ですか? 以下のコードでは:
test_xml = """
<r>
<a/>
<a>
<b/>
</a>
<a>
<b/>
</a>
</r>
"""
test_root = lxml.etree.fromstring(test_xml)
res = test_root.xpath("//following-sibling::*[1]/b")
for node in res:
print test_root.getroottree().getpath(node)
結果は次のとおりです。
/r/a[2]/b
/r/a[3]/b
上記の xpath 評価で使用されるすべてのコンテキスト ノードを取得することは可能ですか。
/r/a[1] /r/a[2] /r/a[2]/b
そして2番目の結果:
/r/a[2] /r/a[3]/b /r/a[3]/b
? 子軸を使用すると、それらのノードが動作しないようにすることができました
element_tree.getpath(elem)
しかし、他の軸はどうですか?
TIAさん、はじめまして