Could you add an attribute selector that "Matches elements that have the specified attribute and don't contain a certain value", ie. in this case, match all paragraphs except those who contain goo?
$html = str_get_html('<p class="foo goo">Hello</p><p class="foo bar">Dear</p><p class="bar car">World</p>');
foreach($html->find("p[class!=goo]") as $p)
printf("%s\n", $p->innertext);
Good idea.
However,
!=is already supported. It checks if an attribute doesn't match the specified value (exact match). In your case this doesn't work, because you need to invert~=(space-separated list of values).CSS has the
:not()pseudo-class for that:I'll see what I can do...
Master now supports the negation pseudo-class (CSS Level 3):
This should do what you need.
[de0e10]
Related
Commit: [de0e10]
Very nice! This is most useful. Feel free to close this issue and I'll reopen it if I see any problems!
How do I do find
ptags whose class contains neitherfoonorbar?DELETE THIS FEATURE REQUEST