I have a quite simple problem but i can\'t seem to resolve it. Let\'s say i have the following code:
zyx
You can combine the tests in the predicate using and
.
Also, this XPath 1.0:
/a/b[preceding-sibling::b/@property='p1'][following-sibling::b/@property='p2']
Note: Don't use //
as first step. Whenever you can replace and
operator by predicates, do it.
In XPath 2.0:
/a/b[. >> ../b[@property='p1']][../b[@property='p2'] >> .]
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']]