XPath : select all following siblings until another sibling

前端 未结 3 1173
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 05:54

Here is an excerpt of my xml :



content





        
3条回答
  •  庸人自扰
    2020-11-27 06:34

    XPath 2.0 has the operators '<<' and '>>' where node1 << node2 is true if node1 precedes node2 in document order. So based on that with XPath 2.0 in an XSLT 2.0 stylesheet where the current node is the node[@id = '1'] you could use

      following-sibling::node[not(text()) and . << current()/following-sibling::node[@od][1]]
    

    That also needs the current() function from XSLT, so that is why I said "with XPath 2.0 in an XSLT 2.0 stylesheet". The syntax above is pure XPath, in an XSLT stylesheet you would need to escape '<<' as '<<'.

提交回复
热议问题