为了找到包含文本“memory”而不是文本“Graphics”的<li>
元素,我尝试了十几种变体:
//li[contains(text(), "memory")] and li[not contains(text(), "Graphics")]
//li[contains(text(), "memory")] and [not contains(text(), "Graphics")]
//li[contains(text(), "memory") and not contains(text(), "Graphics")]
etc etc
虽然我发现Stackoverflow上的帖子指向使用单个布尔运算符(如not
),但我找不到任何解释如何将它们组合起来过滤这样的文本。有什么诀窍?
答案 0 :(得分:2)
not()是XPath中的函数,而不是运算符。你必须写:
//li[contains(text(), "memory") and not(contains(text(), "Graphics"))]