How to select a node using XPath if sibling node has a specific value?

后端 未结 6 1122
温柔的废话
温柔的废话 2020-12-04 08:15

I have the following document:


  abc
  ccc
  
ffffd
zz
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 08:53

    Q: How to select a node using XPath if sibling node has a specific value?
    Because there are only "XPath Axes" for following-siblings and preceding-siblings, you can use one of them if the position is fixed.

    But better: Look for cc were the parent has child bb with value 'zz':

    //cc[../bb='zz']
    

提交回复
热议问题