在simplexml_load_file中加载url时出错
16lz
2021-01-22
I have an rss feed which i would like to read from in my page, i have a local copy of the feed which reads fine but i am required to use the online version. From what i can see i am doing this correctly:
我有一个RSS浏览器,我想在我的页面中读取,我有一个本地的饲料副本,读取正常,但我需要使用在线版本。从我可以看到我正确地做到这一点:
$url ='http//www.numyspace.co.uk/~cgel1/holidays/holidays.xml';
$holidayDoc = simplexml_load_file($url);
However i am met with the following error:
但是我遇到以下错误:
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http//www.numyspace.co.uk/~cgel1/holidays/holidays.xml"
警告:simplexml_load_file()[function.simplexml-load-file]:I / O警告:无法加载外部实体“http // www.numyspace.co.uk /~cgel1 / holidays / holidays.xml”
Why is this not working?
为什么这不起作用?
1 个解决方案
#1
1
$use_errors = libxml_use_internal_errors(true);
$xml = simplexml_load_file("http://www.numyspace.co.uk/~cgel1/holidays/holidays.xml");
if (!$xml) {
//throw new Exception("Cannot load xml source.\n");
}
libxml_clear_errors();
libxml_use_internal_errors($use_errors);
You missed a colon
你错过了冒号