HTML ページtd
の 9 番目の要素をすべて取得したいと考えています。table
私はこれで始めましたが、それを終了する方法がわかりません:
define('GLPI_ROOT', '..');
$content = GLPI_ROOT . "/front/yourpage.html";
$dom = new DOMDocument();
@$dom->loadHTML($content);
$xpath = new DOMXPath($dom);
$attbs = $xpath->query("//table td");
foreach($attbs as $a) {
print $a->nodeValue;
}
そして、私もこれを試しましたが、うまくいきませんでした:
$dom = new DOMDocument();
$dom->loadHTMLFile("yourpage.html");
$tables = $dom->getElementsByTagName('table');
$table = $tables->item(8);
foreach ($table->childNodes as $td) {
if ($td->nodeName == 'td') {
echo $td->nodeValue, "\n";
echo "<script type=\"text/javascript\"> alert('".$td->nodeValue."');</script>";
}
}
私はこのエラーが発生しています:
Warning: DOMDocument::loadHTMLFile(): htmlParseEntityRef: expecting ';' in yourpage.html, line: 33