I have a RSS feed URL and I am using following PHP function to extract values from it.
$xml = simplexml_load_file($url);
Its working perfect when the $url
generates some results. And I am using count()
function to count the length of array thats extracted from RSS feeds.
$length=sizeof($xml->rs[0]->r);
But when there is no result in RSS it gives me error
Trying to get property of non-object in /home/****/public_html/index.php on line 5
So is there a way to echo a message if there are no results in RSS feed URL.
And when i do print_r($xml)
ob no results $xml
, i get
SimpleXMLElement Object ( [@attributes] => Array ( [type] => noresults [code] => 1.1 ) [title] => SimpleXMLElement Object ( ) [subtitle] => SimpleXMLElement Object ( ) [text] => SimpleXMLElement Object ( ) [base] => SimpleXMLElement Object ( ) ) )
I searched everywhere and found no solution.. Thanks for your help.