1

Can someone tell me please How to get the common set of two xpath expressions. That is opposite of Union (not |)

Jagath Jayasinghe
  • 417
  • 3
  • 6
  • 17
  • 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 Answers1

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