Getting the following sibling in an XPath when “following” axis is not supported

前端 未结 1 1986
盖世英雄少女心
盖世英雄少女心 2020-12-11 06:08

I am trying to get the text elements of a table that follows a paragraph that contains a specific text element using XQuery on MS SQL Server. The problem is whenever I use

相关标签:
1条回答
  • 2020-12-11 06:26

    Document order of nodes in XQuery can also be evaluated by using node comparison operators.

    Operator >> applies to two nodes and returns true if the left hand side node follows the right hand side node in document order. For solving your problem, you'd select the first such node.

    In the following code, $blah and $text are the given expressions. The returned value is the first node in $text that follows the first node in $blah.

    let $blah := //w:p[descendant::w:t = "blah"]
    let $text := //w:tbl//w:t/text()
    return $text[. >> $blah[1]][1]
    

    Or, combined into a single expression,

    (//w:tbl//w:t/text()[. >> (//w:p[descendant::w:t = "blah"])[1]])[1]
    
    0 讨论(0)
提交回复
热议问题