Etiket arşivi: xml

TCMB’dan XML ile döviz kuru çekmek

public static void DovizKurAl()
{
XDocument TCMB = XDocument.Load("http://www.tcmb.gov.tr/kurlar/today.xml");
if (TCMB != null)
{
var Kur = (from p in TCMB.Element("Tarih_Date").Elements("Currency")
select new
{
tarih = (string)TCMB.Element("Tarih_Date").Attribute("Tarih"),
kod = (string)p.Attribute("Kod"),
isim = (string)p.Element("Isim"),
alis = (string)p.Element("ForexBuying"),
satis = (string)p.Element("ForexSelling"),
efektifalis = (string)p.Element("BanknoteBuying"),
efektifsatis = (string)p.Element("BanknoteSelling")
});
if (Kur.AsEnumerable().Count() > 0)
{
foreach (var item in Kur)
{
HttpContext.Current.Response.Write(item.tarih + " / " + item.kod + " / " + item.isim + " / " + item.alis + " / " + item.satis + " / " + item.efektifalis + " / " + item.efektifsatis + "
");
}
}
}
}