0

我写了以下代码:

$xmldom = new DOMDocument();
$xmldom->load('http://www.robot-domestici.it/joomla/component/virtuemart/robot-domestici/robot-pulizia-casa?page=shop.feed');

但是加载的文档是空的(这个类别不包含任何产品)并且出现以下错误:

Warning: DOMDocument::load(): Document is empty in http://www.robot-domestici.it/joomla/component/virtuemart/robot-domestici/robot-pulizia-casa?page=shop.feed, line: 1 in C:\Users\Jacopo\Dropbox\Tirocinio\xampp-portable\htdocs\sites\prova\cerca categorie2.php on line 73

Warning: DOMDocument::load(): Start tag expected, '<' not found in http://www.robot-domestici.it/joomla/component/virtuemart/robot-domestici/robot-pulizia-casa?page=shop.feed, line: 1 in C:\Users\Jacopo\Dropbox\Tirocinio\xampp-portable\htdocs\sites\prova\cerca categorie2.php on line 73

并中断执行。显然 URL 是动态生成的,甚至提要的内容也可以更改,所以我不知道哪个 URL 将为空。我要做一些检查,但我不知道我能做什么....我试图将提要存储在一个变量中,但它不起作用:

$str=file_get_contents('http://www.robot-domestici.it/joomla/component/virtuemart/robot-domestici/robot-pulizia-casa?page=shop.feed');
if($str==='')
        return;

我能做些什么?

4

0 回答 0