I want to get the tags with "class" attribute equal to "someclass" but only those tags that hasn't defined the attribute "id".
I tried the following (based on this answer) but didn't work:
$html->find('.someclass[id!=*]');
Note:
I'm using Simple HTML DOM class and in the basic documentation that they give, I didn't find what I need.
From the PHP Simple HTML DOM Parser Manual, under the How to find HTML elements?, we can read:
Your code would become:
This will match elements with a class
someClass
that do not have anid
attribute.My original answer was based on the selection of elements just like we would with jQuery since the Simple HTML DOM Parser claims to support them on their main page where we can read:
My sincere apologies to those who were offended by my original answer and expressed their displeasure in the comments!
Simple HTML DOM class does not support CSS3 pseudo classes which is required for negative attribute matching.
It is simple to work around the limitation without much trouble.