XPath query with descendant and descendant text() predicates

后端 未结 3 1604
半阙折子戏
半阙折子戏 2021-02-05 10:27

I would like to construct an XPath query that will return a \"div\" or \"table\" element, so long as it has a descendant containing the text \"abc\". The one caveat is that it

3条回答
  •  遥遥无期
    2021-02-05 11:20

    //*[self::div|self::table] 
       [descendant::text()[contains(.,"abc")]]  
       [not(descendant::div|descendant::table)]
    

    The problem with contains(//text(), "abc") is that functions cast node sets taking the first node.

提交回复
热议问题