Get all preceding and following siblings for a given node

后端 未结 2 1389
终归单人心
终归单人心 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.

提交回复
热议问题