开发者

Using Simple_Html_Dom Find with 2 attributes

Does anyone know how i could use simple_html_dom's find function to find an html element specifying 2 attributes instead of 1?

Like right now I was using

$area2 = $html->find('td[width="450"]');

开发者_如何学C

but say I want to also specify the height for the object, etc

How could I do it?

Thanks!


I was hoping that $html->find('td[width=450][height=450]'); would work, but apparently not.

This works:

foreach ($html->find("td[width=100]") as $td) {
    $td_html = str_get_html($td->outertext);
    foreach ($td_html->find("td[height=100]") as $td) {
        print "$td\n";
    }
}

And so does this:

function height_filter($x) {
    return isset($x->height) && $x->height == "100";
}

foreach (array_filter($html->find("td[width=100]"),"height_filter") as $td) {
    print "$td\n";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜