Reputation: 2275
Is there a way in Nokogiri to select all elements that don't match a selector. In jQuery I'd use:
:not(*[@class='someclass'])
However the following code gives me an xpath syntax error
dom = Nokogiri::HTML(@file)
dom.css(":not(*[@class='someclass'])")
Upvotes: 6
Views: 6396
Reputation: 130
In addition to ton's answer, if you want to use two classes, that it would like this:
.local:not(.hide)
Upvotes: 4
Reputation: 1513
In CSS3, :not() takes a selector like any other, so it would be:
dom.css(":not(.someclass)")
(untested, but the selector is right)
Upvotes: 12
Reputation: 1604
I'm not sure about the syntax you are using, but this is basically xpath selector you want:
dom.xpath("//wherever/*[not (@class='someclass')]")
Upvotes: 3