Pulling XML with PHP Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
forkinhell
Forum Newbie
Posts: 2
Joined: Sat Nov 21, 2009 10:59 am

Pulling XML with PHP Problem

Post by forkinhell »

I think this should be pretty easy, but for some reason I have spent all day trying to get it to work and failing. (probably due to my inexperience)

All I need to do is get an object, say <description>, from this XML URL: http://themoneyconverter.com/GBP/rss.xml to echo out on the page.

The XML is a list of all currency rates against the GBP.

Any help would be really great.

I have been trying things along the lines of:

Code: Select all

$from = "GBP";
    $url = "http://themoneyconverter.com/$from/rss.xml";
 
$xml = simplexml_load_file($url);
 
    $namespaces = $xml->getDocNamespaces(TRUE);
    var_dump($namespaces);
 
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Pulling XML with PHP Problem

Post by Jonah Bron »

So, does it work? If not, what error do you get? If you haven't already, you should do some reading on this.

http://www.ibm.com/developerworks/libra ... lphp1.html
forkinhell
Forum Newbie
Posts: 2
Joined: Sat Nov 21, 2009 10:59 am

Re: Pulling XML with PHP Problem

Post by forkinhell »

Yeh thanks, that helped. I've ended up with this that seems to work:

Code: Select all

 
$xmlobj = simplexml_load_file("http://themoneyconverter.com/GBP/rss.xml");
 
echo $xmlobj->channel->item [0]->title;
echo "<br />";
echo $xmlobj->channel->item [0]->description;
 
on to the next problem...
Post Reply