[英]convert currency from xml + php
I have an xml source for daily currency http://www.tcmb.gov.tr/kurlar/today.xml我有一个每日货币的 xml 来源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?
如何获取特定数据并从 xml 源转换? :/
:/
i have a search form with:我有一个搜索表格:
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.