Get followin sibling in SQL Server XPath

前端 未结 1 1082
被撕碎了的回忆
被撕碎了的回忆 2021-01-23 09:09

Since SQL Server does not support following-sibling axis - what is the best way to get it? Let\'s say I have XML like this and I would like to get the first \'b\' node after a n

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 09:36

    You could try something like this.

    declare @X xml = '
    
        cat
        Cats don''t like milk
        dog
        not this
        Dogs like everything
        and not this
    '
    
    select @X.query('(/root/b[. >> (/root/a[. = "dog"])[1]])[1]')
    

    0 讨论(0)
提交回复
热议问题