Combining the use of preceding and following sibling in the same xpath query

前端 未结 3 877
礼貌的吻别
礼貌的吻别 2020-12-08 08:16

I have a quite simple problem but i can\'t seem to resolve it. Let\'s say i have the following code:


    zyx
            


        
3条回答
  •  清歌不尽
    2020-12-08 08:47

    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'] >> .]
    

提交回复
热议问题