我有这个PHP脚本:
<?php
libxml_use_internal_errors(true);
/* Createa a new DomDocument object */
$dom = new DomDocument;
$dom_grep = new DomDocument;
/* Load the HTML */
$dom->loadHTMLFile("http://domain.com/catalog/0_1.html");
/* Create a new XPath object */
$xpath = new DomXPath($dom);
/* Query all <table> nodes containing specified class name */
$nodes = $xpath->query("/html/.//table[@class='right']");
/* Set HTTP response header to plain text for debugging output */
header("Content-type: text/plain");
/* How to make Xpath in code below??? */
foreach ($nodes as $i => $node) {
$child[$i]["title"] = $node->query("//tr[@class='bg3']//h3");
$child[$i]["href"] = $node->query("a['href=/catalog/details']");
}
}
?>
但是我在结果中遇到了这个错误: &#34;致命错误:调用未定义的方法DOMElement :: query()&#34;在$ child array
中如何在$ nodes中进行另一个xpath查询?
谢谢!