I am trying to access RSS live cricket score feed of espncricinfo.
My php code is like this
$xml = simplexml_load_file("http://static.cricinfo.com/rss/livescores.xml");
but it is throwing an error like this.
Warning: simplexml_load_file(http://static.cricinfo.com/rss/livescores.xml) [function.simplexml-load-file]: failed to open stream: Permission denied in /home/www/java8.in/txtWeb/demo.php on line 11
looking for a solution.
Your code actually works ,but you need to have allow_url_fopen to be set 1 or ON to achieve what you are doing.
Check the PHP Manual here on how to do that.
<?php
$xml = simplexml_load_file("http://static.cricinfo.com/rss/livescores.xml");
print_r($xml);
OUTPUT:
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => Cricinfo Live Scores [ttl] => 2 [link] => http://www.cricinfo.com [description] => Latest scores from Cricinfo [copyright] => (c)Cricinfo [language] => en-gb [pubDate] => Tue, 04 Feb 2014 19:12:01 +0000 [item] => Array ( [0] => SimpleXMLElement Object ( [title] => Bangladesh v Sri Lanka 314/5 * [link] => http://www.cricinfo.com/ci/engine/match/690349.html?CMP=OTC-RSS [description] => Bangladesh v Sri Lanka 314/5 * [guid] => http://www.cricinfo.com/ci/engine/match/690349.html ) [1] => SimpleXMLElement Object ( [title] => South Africa 300/10 v South African Composite XI 24/3 * [link] => http://www.cricinfo.com/ci/engine/match/714095.html?CMP=OTC-RSS [description] => South Africa 300/10 v South African Composite XI 24/3 * [guid] => http://www.cricinfo.com/ci/engine/match/714095.html ) [2] => SimpleXMLElement Object ( [title] => Guyana 36/1 * v Windward Islands [link] => http://www.cricinfo.com/ci/engine/match/708797.html?CMP=OTC-RSS [description] => Guyana 36/1 * v Windward Islands [guid] => http://www.cricinfo.com/ci/engine/match/708797.html ) [3] => SimpleXMLElement Object ( [title] => Sri Lanka Cricket Women's XI v England Academy Women [link] => http://www.cricinfo.com/ci/engine/match/710579.html?CMP=OTC-RSS [description] => Sri Lanka Cricket Women's XI v England Academy Women [guid] => http://www.cricinfo.com/ci/engine/match/710579.html ) [4] => SimpleXMLElement Object ( [title] => Sydney Sixers v Perth Scorchers [link] => http://www.cricinfo.com/ci/engine/match/654097.html?CMP=OTC-RSS [description] => Sydney Sixers v Perth Scorchers [guid] => http://www.cricinfo.com/ci/engine/match/654097.html ) ) ) )
<?php
$url = "http://static.cricinfo.com/rss/livescores.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xmlresponse = curl_exec($ch);
$xml=simplexml_load_string($xmlresponse);
print_r($xml);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With