开发者

How do I check if a RSS feed is working?

开发者 https://www.devze.com 2022-12-22 17:18 出处:网络
For example, if there is an RSS feed and for some reason it is down or cannot be grabbed I want to display a simple message saying \"feed cannot be grabbed\".

For example, if there is an RSS feed and for some reason it is down or cannot be grabbed I want to display a simple message saying "feed cannot be grabbed".

Right now PHP spits out a really ugly warning message.

note:I do not need to know whether it is valid. I just need to know if the feed actually works. I do not want to turn off warnings. I want to spit out a simple echo if the feed is not working. I am using PHP no libraries.

Any thanks would be awesome!

Ri开发者_运维技巧ck


You can manually handle any XML parsing errors by using the libxml_use_internal_errors function.

An example can be found here


You can do this:

error_reporting(E_WARNING);

if (!$xmlDoc->load($url)){ 

 echo ("Not content could be loaded.");

}
0

精彩评论

暂无评论...
验证码 换一张
取 消