Simple html dom: how to get a tag without a specific attribute

I want to get tags with the "class" attribute equal to "someclass", but only those tags that have not defined the "id" attribute.

I tried the following (based on this answer) but did not work:

$html->find('.someclass[id!=*]');

Note:

I use the Simple HTML DOM class and in the base documentation they give, I did not find what I need.

+5
source share
2 answers

The simple HTML DOM class does not support CSS3 pseudo-classes , which is required to map negative attributes.

Just get around the limitation without any problems.

$nodes = array_filter($html->find('.something'), function($node){return empty($node->id);});
+3

PHP Simple HTML DOM Parser Manual HTML-?, :

[! attribute] , .

:

$html->find('.someclass[!id]');

someClass, id.


, jQuery, Simple HTML DOM Parser , :

HTML , jQuery.

, !

+5

All Articles