Combining the use of preceding and following sibling in the same xpath query
xpath
Solution
XPath 1.0:
/a/b[preceding-sibling::b/@property='p1' and following-sibling::b/@property='p2']
XPath 2.0: The expression above has some quirks in XSLT 2.0, it is better to use the new and safer operators `<<` (before) and `>>` (after).
/a/b[../b[@property='p2'] << . and . >> ../b[@property='p1']]
Problem
I have a quite simple problem but i can't seem to resolve it. Let's say i have the following code: ``` <a> <b property="p1">zyx</b> <b>wvu</b> <b>tsr</b> <b property="p2">qpo</b> <b>qcs</b> </a> ``` I want to select the nodes between the `b` node who has a `property="p1"` and the `b` node who has `property="p2"`. I can do either of those with the preceding-sibling and the following-sibling axis but I can't seem to find how to combine both.