DOM加载一个空文档 - php

时间:2013-03-19 20:48:26

标签: xml dom domdocument php

我写了以下代码:

$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是以dinamically方式生成的,甚至Feed的内容也可以改变,所以我不知道哪个URL是空的。我要做一些检查,但我无法弄清楚我能做些什么.... 我试图将Feed存储在变量中,但它不起作用:

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

我能做什么?

0 个答案:

没有答案