XPath to select following-sibling

前端 未结 2 1048
北恋
北恋 2020-12-30 10:19

This is the code that I currently have:

  • <
2条回答
  •  自闭症患者
    2020-12-30 11:21

    This xpath worked for me in Chrome, using your html:

    //span[contains(text(), 'ABZ')]/../following-sibling::section/span[@name='edit']
    

    Edit

    The .. means to go up a level. The .. takes the selector from span to section. Then the following-sibling finds the section after the parent section of your matching span.

    Your original selector was matching span, then looking for a following-sibling to span.

提交回复
热议问题