我正在使用file_get_contents()
从其他网站获取数据,但我需要使用类inputpanelfields提取多个表记录,
$d = new DOMDocument
libxml_use_internal_errors(true)
$d->loadHTML($html)
$table = $x->query('//table[contains(@class, "inputpanelfields")]')
我该怎么做?
答案 0 :(得分:0)
DomDocument::saveHTML()
接受一个参数只保存文档的一个子集。因此,您可以输出第一个匹配表的HTML,如下所示:
echo $d->saveHTML($table[0]);