XPath query with descendant and descendant text() predicates

后端 未结 3 1647
半阙折子戏
半阙折子戏 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:16

    you could try:

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

    does that help?

提交回复
热议问题