示例#1
0
        //XML
        public static string[] TlKarsiligiFromMerkez()
        {
            string[] kurs = new string[4];

            if (HttpContext.Current.Session["usdal"] == null)
            {
                //'Dim kod, tur As String
                XmlTextReader rdr   = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
                XmlDocument   MyXml = new XmlDocument();
                XmlNodeList   MyNode;

                //'kod = kodu.ToString()
                //'tur = turu.ToString()
                //'Deðiþkenlerimizi stringe çeviriyoruz.

                try
                {
                    MyXml.Load(rdr);
                    //' internetteki xml belgesini uygulamamýza yüklüyoruz.
                    //MyNode = MyXml.SelectNodes("/Tarih_Date/Currency[@Kod ='USD']/ForexSelling");
                    //HttpContext.Current.Session["usdsat"] = MyNode.Item(0).InnerXml.ToString().Replace(".", ",");
                    //MyNode = MyXml.SelectNodes("/Tarih_Date/Currency[@Kod ='EUR']/ForexSelling");
                    //HttpContext.Current.Session["eursat"] = MyNode.Item(0).InnerXml.ToString().Replace(".", ",");
                    MyNode = MyXml.SelectNodes("/Tarih_Date/Currency[@Kod ='USD']/ForexBuying");
                    HttpContext.Current.Session["usdal"] = MyNode.Item(0).InnerXml.ToString().Replace(".", ",");
                    MyNode = MyXml.SelectNodes("/Tarih_Date/Currency[@Kod ='EUR']/ForexBuying");
                    HttpContext.Current.Session["eural"] = MyNode.Item(0).InnerXml.ToString().Replace(".", ",");
                }
                catch { }
            }
            kurs[0] = HttpContext.Current.Session["usdal"].ToString();
            kurs[1] = HttpContext.Current.Session["eural"].ToString();
            //kurs(1) = HttpContext.Current.Session("eursat");
            //kurs(2) = HttpContext.Current.Session("usdsat");


            return(kurs);
            //'seçilen node un verisi stringe çevrilip geri döndürülür.
        }