Get all preceding and following siblings for a given node

后端 未结 2 1350
终归单人心
终归单人心 2021-01-27 20:08

I have the following XML snippet:


    
        Specification_Characteristics
        

        
相关标签:
2条回答
  • 2021-01-27 21:02

    One way is brute-force:

    /root/CharacteristicUse/Value[ValueID='555']/preceding-sibling::* | /root/CharacteristicUse/Value[ValueID='555']/following-sibling::*
    

    This includes the "UseArea" node also, not sure if you want that.

    Or if what you want is just all the values that are NOT a particular value, then

    /root/CharacteristicUse/Value[not(ValueID='555')]
    

    is more direct.

    0 讨论(0)
  • 2021-01-27 21:03

    I found the answer. The xpath looks like:

    /root/CharacteristicUse/Value[ValueID='555']/following-sibling::Value | /root/CharacteristicUse/Value[ValueID='555']/preceding-sibling::Value
    
    0 讨论(0)
提交回复
热议问题