【问题标题】:Simple_html_dom find table with custom styleSimple_html_dom 查找具有自定义样式的表
【发布时间】:2014-04-11 22:05:54
【问题描述】:
如何找到有风格的表格?我知道它有样式 attr:
style="border: 1px solid #aaaaaa;border-collapse:collapse;width:600px;background:#ffffff;text-align:center;margin-top:10px;"
但是如何将它与“查找”一起使用?
我试过了:
$scrap['content']->find('table[style*=border: 1px solid #aaaaaa; border-collapse: collapse; width: 600px; background: #ffffff; text-align: center; margin-top: 10px;]');
但它不起作用
【问题讨论】:
标签:
php
styles
find
simple-html-dom
【解决方案1】:
它对我有用:
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