Search code examples
domxpathxpathquery

How to use "not" in XPath?


I want to write something of the sort:

//a[not contains(@id, 'xx')]

(meaning all the links who's 'id' attribute doesn't contain the string 'xx')

I can't find the right syntax.


Solution

  • not() is a function in XPath (as opposed to an operator), so

    //a[not(contains(@id, 'xx'))]