#22 How to find multiple attributes

v1.0_(example)
open
nobody
None
1
2013-12-09
2013-05-02
Alon
No

Hi,
I've just started using the parser and I need to parse an HTML page and get 'tr' tags with class 'even' that don't have an 'id' attribute. I tried a couple of approaches like:
$html->find('tr.even[!id]');
or
$html->find('tr[!id].even');

but none seems to work.
Is it possible to search for multiple attributes?

thanks,
Alon.

Discussion

  • pixeline
    pixeline
    2013-12-08

    I would select all tr.even then in the foreach, bypass those that do have the "id" attribute

    $ret = $html->find('div[id]'); foreach($html->find('tr[class=even]') as $e) if(!$e->id){ // process the data... } }

     
    Last edit: pixeline 2013-12-08
  • John Schlick
    John Schlick
    2013-12-09

    Remember that find returns an array of dom objects (this is implicit in the answer pixeline gave).