PHP simpleXML parsing

Posted by FFish on Stack Overflow See other posts from Stack Overflow or by FFish
Published on 2010-03-17T11:21:54Z Indexed on 2010/03/17 11:31 UTC
Read the original article Hit count: 585

Filed under:
|
|

I need currency conversion, euro to dollar.
The European Central bank provides the rates here:
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
I can get the USD rate by using the first node, but what if they change the order?
Do I need something more reliable? I have no idea how..

$xml = @simplexml_load_file('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
echo "dollar: " . $xml->Cube->Cube->Cube[0]->attributes()->rate;

© Stack Overflow or respective owner

Related posts about php

Related posts about simplexml