2012-05-02 89 views
0

我有一個rss飼料,我想從我的網頁讀取,我有一個飼料的本地副本,它讀取的很好,但我需要使用在線版本。從我可以看到我是這個做正確:加載url在simplexml_load_file中的錯誤

 $url ='http//www.numyspace.co.uk/~cgel1/holidays/holidays.xml'; 
     $holidayDoc = simplexml_load_file($url); 

但是我正在會見了以下錯誤:

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"

這是爲什麼不工作?

+1

你錯過了在URL的協議部分冒號:通過'http://' – shanethehat

回答

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); 

你錯過了一個冒號

+0

謝謝,不敢相信我錯過了。 –