Simple_html_dom查找具有自定义样式的表

时间:2014-03-08 17:15:40

标签: php styles find simple-html-dom

如何找到有风格的桌子?我知道它有风格attr:

  

style =“border:1px solid #aaaaaa; border-collapse:collapse; width:600px; background:#ffffff; text-align:center; margin-top:10px;”

但如何使用“find”?

我试过了:

$scrap['content']->find('table[style*=border: 1px solid #aaaaaa; border-collapse: collapse; width: 600px; background: #ffffff; text-align: center; margin-top: 10px;]');

但它不起作用

1 个答案:

答案 0 :(得分:0)

它对我有用:

require_once('simple_html_dom.php');

$html = <<<EOF
<table>foo</table>
<table style="border: 1px solid #aaaaaa; border-collapse: collapse; width: 600px; background: #ffffff; text-align: center; margin-top: 10px;">bar</table>
EOF;

$doc = str_get_html($html);
echo $doc->find('table[style*=border: 1px solid #aaaaaa; border-collapse: collapse; width: 600px; background: #ffffff; text-align: center; margin-top: 10px;]', 0)->text();
//=> bar
相关问题