simple html dom: how get a tag without certain attribute

css-selectors, html-parsing, parsing, php, simple-html-dom

Solution

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.

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

Problem

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.

Original source