C# XML Çekme |
4 Mesajlar | 1.038 Okunma |
DateTime Tarih = DateTime.Today.AddDays(-1);
string ay = Tarih.Month.ToString().PadLeft(2, '0');
string gun = Tarih.Day.ToString().PadLeft(2, '0');
string kur = string.Format("http://www.tcmb.gov.tr/kurlar/{0}{1}/{2}{1}{0}.xml", Tarih.Year, ay, gun);
var xmlDoc1 = new XmlDocument();
xmlDoc1.Load(kur);
string USDd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='USD']/ForexBuying").InnerXml;
usddunku.Text = string.Format("{1}", tarih.ToShortDateString(), USDd);
string EURd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='EUR']/ForexBuying").InnerXml;
eurodunku.Text = string.Format("{1}", tarih.ToShortDateString(), EURd);
string GBPd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='GBP']/ForexBuying").InnerXml;
gbpdunku.Text = string.Format("{1}", tarih.ToShortDateString(), GBPd);
string CHFd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='CHF']/ForexBuying").InnerXml;
chfdunku.Text = string.Format("{1}", tarih.ToShortDateString(), CHFd);
try{
DateTime Tarih = DateTime.Today.AddDays(-1);
string ay = Tarih.Month.ToString().PadLeft(2, '0');
string gun = Tarih.Day.ToString().PadLeft(2, '0');
string kur = string.Format("http://www.tcmb.gov.tr/kurlar/{0}{1}/{2}{1}{0}.xml", Tarih.Year, ay, gun);
var xmlDoc1 = new XmlDocument();
xmlDoc1.Load(kur);
string USDd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='USD']/ForexBuying").InnerXml;
usddunku.Text = string.Format("{1}", tarih.ToShortDateString(), USDd);
string EURd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='EUR']/ForexBuying").InnerXml;
eurodunku.Text = string.Format("{1}", tarih.ToShortDateString(), EURd);
string GBPd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='GBP']/ForexBuying").InnerXml;
gbpdunku.Text = string.Format("{1}", tarih.ToShortDateString(), GBPd);
string CHFd = xmlDoc1.SelectSingleNode("Tarih_Date/Currency [@Kod='CHF']/ForexBuying").InnerXml;
chfdunku.Text = string.Format("{1}", tarih.ToShortDateString(), CHFd);
}
catch
{
Messagebox.show("Bugünün verisine ulaşılamadı !");
}