consider following example:
<root>
<instruments>
<flute>
<baz>bazik</baz>
</flute>
<guitar>
<deep>
<baz>more 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?
0 votes. Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
XPath assertion uses XPath expression to select the target node and its values. It compares the result of an XPath expression to an expected value. XPath is an XML query language for selecting nodes from an XML. Step 1 − After clicking Add Assertion, select Assertion Category – Property Content.
the key is to use predicate [descendant::baz]
so the expression can be
/root/instruments/*[descendant::baz]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With