Following the post here Combining the use of preceding and following sibling in the same xpath query I am wanting to do the same except I want to get nodes up to the first occurrence of p2.
So the modified example data is
<a>
<b property="p1">zyx</b>
<b>wvu</b>
<b>tsr</b>
<b>dcv</b>
<b property="p2">qpo</b>
<b>qcs</b>
<b property="p2">wee</b>
<b>tbg</b>
<b>rty</b>
<b property="p2">qwe</b>
<b>jkl</b>
</a>
I have tried
/a/b[preceding-sibling::b/@property='p1' and following-sibling::b[1]/@property='p2']
which gives me dcv, qcs, and rty. Then I tried
/a/b[preceding-sibling::b/@property='p1' and (following-sibling::b/@property='p2')[1]]
which gives me wvu, tsr, dcv, qpo, qcs, wee, tbg, and rty.
What I actually need is from p1 to the first p2 or wvu, tsr, and dcv. I have tried almost every combination of [1] but have failed and would like some help on the construct.