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.
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.
not()
is a function in XPath (as opposed to an operator), so
//a[not(contains(@id, 'xx'))]
None of these answers worked for me for python. I solved by this
a[not(@id='XX')]
Also you can use or condition in your xpath by |
operator. Such as
a[not(@id='XX')]|a[not(@class='YY')]
Sometimes we want element which has no class. So you can do like
a[not(@class)]
not() function combined with "and" operator worked in my case. I am using typescript. For example,
contains(text(),'textIWantToBeMatched') and not(contains(text(),'subTextIDoNotWantToBeMatched'))
tags but not the tag inside them? imagine something like
– CodeMonkey Sep 03 '19 at 13:07text textTEXTtext text
. i want all the text in p but not the TEXT in a. is that possible with XPath? This isn't exactly my case, it's a little more complicated than that but its more or less the same.