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 开发者_StackOverflow中文版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!!!
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;
?>
$site = file_get_contents("http://www.tcmb.gov.tr/kurlar/today.xml");
preg_match_all("'EURO</CurrencyName><ForexBuying>(.*)</ForexBuying><ForexSelling>(.*)<CrossRateOther>(.*)<'U", $site, $durum);
preg_match_all("'POUND STERLING</CurrencyName><ForexBuying>(.*)</ForexSelling>(.*)<CrossRateOther>(.*)<'U", $site, $GBP);
$tl = $durum[1][0];
$dolar = $durum[3][0];
精彩评论