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.");
}
精彩评论