woolyg Posted December 8, 2008 Share Posted December 8, 2008 Hi all, I'm trying to read info from an XML feed and print it to my PHP page. the XML feed is here:http://xurrency.com/nzd/feed And the code I am using is here: <?php # INSTANTIATE CURL. $curl = curl_init(); # CURL SETTINGS. curl_setopt($curl, CURLOPT_URL, "http://xurrency.com/nzd/feed"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); # GRAB THE XML FILE. $xmlTwitter = curl_exec($curl); //echo $xmlTwitter; curl_close($curl); $xml = simplexml_load_string($xmlTwitter); foreach($xml->xpath('//item') as $k => $item) { // FOR 17 $creator= $item->xpath('//dc:creator'); echo $creator."<br />"; } //CLOSE FOR 17 ?> If I un-comment "echo $xmlTwitter;", it displays all of the XML, but I'm having trouble picking the info out of the file. Could anyone please help? Thanks, WoolyG Link to comment https://forums.phpfreaks.com/topic/136022-curl-reading-xml-help-pls/ Share on other sites More sharing options...
JonnoTheDev Posted December 8, 2008 Share Posted December 8, 2008 Why are you using CURL rather than loading the feed using simple_xml? simplexml_load_file("http://xurrency.com/nzd/feed"); Link to comment https://forums.phpfreaks.com/topic/136022-curl-reading-xml-help-pls/#findComment-709346 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.