How to select nodes that has X as descendant using xpath
consider following example:
<root>
<instruments>
<flute>
<baz>bazik</baz>
</flute>
<guitar>
<deep>
<baz>mor开发者_运维技巧e bazik</baz>
</deep>
</guitar>
<drum>
<foo>fooled</foo>
</drum>
</instruments>
</root>
I want to select flute
and guitar
because they both contain baz
as a descendant node. How can I do that?
the key is to use predicate [descendant::baz]
so the expression can be
/root/instruments/*[descendant::baz]
精彩评论