Getting Exchange Rates from the Internet

I want to do to get exchange rates from the Internet. I found this feature after lengthy research.

protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
        string xmlResult = null;
        string url;
        url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" + TextBox1.Text + "&ToCurrency=" + TextBox2.Text + "";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader resStream = new StreamReader(response.GetResponseStream());
        XmlDocument doc = new XmlDocument();
        xmlResult = resStream.ReadToEnd();
        doc.LoadXml(xmlResult);
        Label1.Text = "Current Exchange Rate for " + TextBox1.Text.ToUpper() + " ---> " + TextBox2.Text.ToUpper() + " value " + doc.GetElementsByTagName("double").Item(0).InnerText;
        }
        catch(Exception ex)
        {
            Label1.Text="Not a valid Currency or Try again later";
        }
    } 

But it http://www.webservicex.net/does not support AZN (Azerbaijani manat) for usd and vice versa. I want to do this, if possible, connect to the Internet and get bets. Else uses a written function to convert (I already wrote).

What do you advise, how can I get current rates for USD and AZN (or just get the result by sending USD or AZN)? Is there a way to get it from a Windows Forms application?

+5
source share
3 answers

This simple algorithm will give you everything you need in a list of key value pairs.

public static List<KeyValuePair<string, decimal>> GetCurrencyListFromWeb(out DateTime   currencyDate)
    {
        List<KeyValuePair<string, decimal>> returnList = new List<KeyValuePair<string, decimal>>();
        string date = string.Empty;
        using (XmlReader xmlr = XmlReader.Create(@"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"))
        {
            xmlr.ReadToFollowing("Cube");
            while (xmlr.Read())
            {
                if (xmlr.NodeType != XmlNodeType.Element) continue;
                if (xmlr.GetAttribute("time") != null)
                {
                    date = xmlr.GetAttribute("time");
                }
                else returnList.Add(new KeyValuePair<string, decimal>(xmlr.GetAttribute("currency"), decimal.Parse(xmlr.GetAttribute("rate"), CultureInfo.InvariantCulture)));
            }
            currencyDate = DateTime.Parse(date);
        }
        returnList.Add(new KeyValuePair<string, decimal>("EUR", 1));
        return returnList;
    }
+4
source

http://www.webservicex.net/ AZN ( ) usd

? -, .

AZN, , . OANDA (http://www.oanda.com) , USD (http://www.oanda.com/currency/cross-rate/result?quotes=GBP"es=EUR& = JPY & = CHF & = USD & = AZN & = Get + + +% 3E)

, webservicesx.net -, .

. FXCM Oanda API, - , .

, AZN , USD. FOREX, - - -.

Windows Forms?

API , , winforms, webforms, powershell vb script, API , , , , .

0

, . Google, -, , , AZN. , . :
http://www.transfermate.com/en/free_currency_converter.asp

, , . :

Reuse the written function to convert (I 'already written).

If you cannot find a solution that already exists, create it yourself.

Also try: https://developers.google.com/finance/ and http://openexchangerates.org/

0
source