I'm writing an xpath expression to achieve this:
//parent[(childA[contains(.,"foo")] or childB[contains(.,"foo")]) AND (childA[contains(.,"bar")] or childB[contains(.,"bar")])]
which is to select a parent whose children (childA or childB or both childA and childB together) contain both the strings "foo" and "bar".
I'm not sure whether parenthesis before and after AND is correctly used. Can xpath have parenthesis like this?
Thanks in advance!!
See http://www.w3.org/TR/xpath/#section-Expressions. In particular:
Parentheses may be used for grouping.
and
NOTE: The effect of the above grammar is that the order of precedence is
(lowest precedence first):
or
and
=, !=
<=, <, >=, >
and the operators are all left associative. For example, 3 > 2 > 1 is
equivalent to (3 > 2) > 1, which evaluates to false.
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