Kütüphane
|
1 |
using System.Xml.Linq; |
Döviz Kuru Çekme
Class
|
1 2 3 4 5 6 |
public class DovizKurlari { public string Ad { get; set; } public string AlisFiyat { get; set; } public string SatisFiyat { get; set; } } |
Controller
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
List<DovizKurlari> DovizKurlari() { List<DovizKurlari> DovizList = new List<DovizKurlari>(); try { XDocument xDoc = XDocument.Load("https://www.tcmb.gov.tr/kurlar/today.xml"); DovizList = xDoc.Descendants("Currency").Where(x => (string)x.Attribute("Kod") == "USD" || (string)x.Attribute("Kod") == "EUR" || (string)x.Attribute("Kod") == "GBP") .Select(o => new DovizKurlari { Ad = (string)o.Element("Isim"), AlisFiyat = (string)o.Element("ForexBuying"), SatisFiyat = (string)o.Element("ForexSelling"), }) .ToList(); return DovizList; } catch (Exception) { return null; } } |
Hava Durumu Çekme
Class
|
1 2 3 4 5 6 7 8 |
public class HavaDurumu { public string Bolge { get; set; } public string Ili { get; set; } public string Merkez { get; set; } public string Durum { get; set; } public string MaksimunDerece { get; set; } } |
Controller
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
List<HavaDurumu> HavaDurumu() { List<HavaDurumu> HavaDurumuList = new List<HavaDurumu>(); try { XDocument xDoc = XDocument.Load("https://www.mgm.gov.tr/FTPDATA/analiz/sonSOA.xml"); HavaDurumuList = xDoc.Descendants("sehirler").Where(x => (string)x.Element("Merkez") == "DÜZCE").Select(o => new HavaDurumu { Bolge = (string)o.Element("Bolge"), Merkez = (string)o.Element("Merkez"), Durum = (string)o.Element("Durum"), Ili = (string)o.Element("ili"), MaksimunDerece = (string)o.Element("Mak"), }).ToList(); return HavaDurumuList; } catch (Exception) { return null; } } |
gelen stringleri nasıl ekrandaki textbox a yazdırabilirim