Can someone tell me please How to get the common set of two xpath expressions. That is opposite of Union (not |)
Asked
Active
Viewed 550 times
1
-
In XPath 2.0 - you have `intersect` - prior to that there's the `Kaysian` method - see: http://stackoverflow.com/questions/538293/find-common-parent-using-xpath – Jon Clements May 14 '13 at 13:04
1 Answers
3
This is the well-known Kayessian formula (identity) for selecting the intersection of two node-sets $ns1
and $ns2
:
$ns1[count(. | $ns2) = count($ns2)]
This formula can be used in all versions of XPath, including 1.0. Just substitute $ns1
and $ns2
with your specific XPath expressions that select the two node-sets you want to intersect.

Dimitre Novatchev
- 240,661
- 26
- 293
- 431
-
-
@Ravi, You are welcome. Thank you for asking such interesting question. – Dimitre Novatchev May 15 '13 at 14:21