I am using a remote xml file to get currency values for a site I am doing, however the script I created is very ugly and awkward to maintain

The xml file is here

http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

As you can see the layout is somewhat different from other XML files I have used, and I am unsure how to effectively parse it to get the information I am looking for - which is normally the rate for USD and GBP

Does anyone have any ideas on how to effectively parse this document

Also is there anyway to prevent calls to the xml file every time unless it changes? Or cache it - as the xml file only changes once a day

    PHP has several parser extensions to choose from. It's [man]XML[/man] expat interface would be simplest here (especially for such a simple XML file).

    And as for preventing excess calls; each time you request the file, record the current time; don't make the request unless the recorded time is less than a day old.

      Write a Reply...