In order to find <li> elements that contain the text “memory” but not the text “Graphics”, I have tried a dozen variation of:
//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
While I’ve found posts on Stackoverflow that point to the use of individual boolean operators like not, I can find nothing that explains how to combine them to filter text like this. What’s the trick?
not() is a function in XPath, not an operator. You have to write: