我loadHTMLFile
用来从 HTML 页面获取表格的 td 内容,它运行良好,
define('GLPI_ROOT', '..');
$dom = new DOMDocument();
$dom->loadHTMLFile(GLPI_ROOT . "/front/yourpage.html");
$tables = $dom->getElementsByTagName('table');
$table = $tables->item(9);
$ana = $table->getElementsByTagName('td');
foreach ($ana as $td) {
if ($td->nodeName == 'td') {
echo $td->nodeValue,"<br/>";
}
}
但我真正想要的只是获取td
每个tr
元素的第二个元素table