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'])")
In CSS3, :not() takes a selector like any other, so it would be:
dom.css(":not(.someclass)")
(untested, but the selector is right)
In addition to ton's answer, if you want to use two classes, that it would like this:
.local:not(.hide)
I'm not sure about the syntax you are using, but this is basically xpath selector you want:
dom.xpath("//wherever/*[not (@class='someclass')]")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With