XPath select all elements between two specific elements

前端 未结 4 604
离开以前
离开以前 2020-11-27 05:17

I have a following xml:


    
    

text

text

text

te

4条回答
  •  余生分开走
    2020-11-27 05:22

    I think there's a much simpler and probably faster solution: you want all preceding siblings of the second divider that have at least one preceding sibling divider:

    /doc/divider[2]/preceding-sibling::p[preceding-sibling::divider]
    

    It gets a bit more complex, of course, if you want to find the paras between the second and third dividers: then you want something more like Daniel Haley's solution.

提交回复
热议问题