Jump to content

CURL / reading XML help pls?


woolyg

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.