我得到了上面的错误,并试图打印出对象,看看我如何访问它内部的数据,但它只回显DOMNodeList对象()
function dom() {
$url = "http://website.com/demo/try.html";
$contents = wp_remote_fopen($url);
$dom = new DOMDocument();
@$dom->loadHTML($contents);
$xpath = new DOMXPath($dom);
$result = $xpath->evaluate('/html/body/table[0]');
print_r($result);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Wordpress,因此解释了wp_remote_fopen函数.我试图从$ url回显第一个表