views:

66

answers:

1

Hi friends,

I have an xml source for daily currency http://www.tcmb.gov.tr/kurlar/today.xml

and i need to make a currency optional search for a portal. how can I get a specific data and convert from xml source? :/

i have a search form with:

  • price input
  • currency list box (euro, dollar)

and I need to convert the value from form for products price currency.

Appreciate helps!! thanks!!!

A: 

You can read the conversion rate like this:

<?php   

$x = simplexml_load_file('http://www.tcmb.gov.tr/kurlar/today.xml');

// Use GBP as an example
$code = 'GBP';

$nodes = $x->xpath('//Currency[@CurrencyCode="' . $code . '"]');

echo 'Buying Rate for ' . $code . 'is ' . (string)$nodes[0]->BanknoteBuying;


?>
Greg
hmm, thats cool. so i can make the $code dynamically from form submit and use for math action : ) thanks...
artmania