Here is one possible solution:
First:
I want to match consecutive sibling
nodes in a XML tree to certain
predefined rules for example if there
are three sibling nodes occurring
immediately one after the other and
they have the attributes value="A",
value="B" and value="C",
//*[@value='A'
and
following-sibling::*[1]/@value='B'
and
following-sibling::*[2]/@value='C']
Then:
I want to extract all such consecutive
sequence of nodes from the XML tree
...
//*[@value='A'
and
following-sibling::*[1]/@value='B'
and
following-sibling::*[2]/@value='C']
|
//*[@value='A'
and
following-sibling::*[1]/@value='B'
and
following-sibling::*[2]/@value='C']
/following-sibling::*[position() = 1 or position()=2]
Here is how the selection looks like in the true XPathVisualizer (_http://www.topxml.com/xpathvisualizer/ -- this link has a trojan -- click only if you have good malware protection. Alternatively, contact me for the app.):
Finally:
I want the XPATH query to match the
first node/last node in such a
sequence
//*[@value='A'
and
following-sibling::*[1]/@value='B'
and
following-sibling::*[2]/@value='C']
|
//*[@value='A'
and
following-sibling::*[1]/@value='B'
and
following-sibling::*[2]/@value='C']
/following-sibling::*[position()=2]