29 Kasım 2015 Pazar

C# Kur Fiyatlarını İnternet' ten Çekmek



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;



namespace Kur_Fiyatları_v2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string today = "http://www.tcmb.gov.tr/kurlar/today.xml";
            var xmlDoc = new XmlDocument();
            xmlDoc.Load(today);

            // Xml içinden tarihi alma - gerekli olabilir
            DateTime exchangeDate = Convert.ToDateTime(xmlDoc.SelectSingleNode("//Tarih_Date").Attributes["Tarih"].Value);

            string USD = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='USD']/BanknoteSelling").InnerXml;
            string EURO = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='EUR']/BanknoteSelling").InnerXml;
            string POUND = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='GBP']/BanknoteSelling").InnerXml;
            string JPY = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='JPY']/BanknoteSelling").InnerXml;

            listBox1.Items.Add(string.Format("Tarih  {0}   USD/TRY       : {1}", exchangeDate.ToShortDateString(), USD));
            listBox1.Items.Add(string.Format("Tarih  {0}   EURO/TRY      : {1}", exchangeDate.ToShortDateString(), EURO));
            listBox1.Items.Add(string.Format("Tarih  {0}   POUND/TRY     : {1}", exchangeDate.ToShortDateString(), POUND));
            listBox1.Items.Add(string.Format("Tarih  {0}   JPY/TRY       : {1}", exchangeDate.ToShortDateString(), JPY));

        }
    }
}

Paylaş:

0 yorum:

Yorum Gönder

Popüler

Son

Kategoriler