Du kan jo kode det praecis ligesom du vil have det.
Variant:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml;
namespace E
{
public class Program
{
private static readonly CultureInfo dadk = new CultureInfo("da-DK", false);
public static List<decimal> GetRate(List<DateTime> date, string currency)
{
XmlDocument doc = new XmlDocument();
doc.Load("
http://www.nationalbanken.dk/_vti_bin/DN/DataService.svc/CurrencyRatesHistoryXML?lang=da");
XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);
xnm.AddNamespace("gesmes", "
http://www.gesmes.org/xml/2002-08-01");
xnm.AddNamespace("default", "
http://www.ecb.int/vocabulary/2002-08-01/eurofxref");
List<decimal> res = new List<decimal>();
foreach(DateTime dt in date)
{
string datestr = dt.ToString("yyyy-MM-dd");
string ratestr = doc.SelectSingleNode("/gesmes:Envelope/default:Cube/default:Cube[@time='" + datestr + "']/default:Cube[@currency='" + currency + "']/@rate", xnm).Value;
res.Add(decimal.Parse(ratestr, dadk));
}
return res;
}
public static void Main(string[] args)
{
foreach(decimal d in GetRate(new List<DateTime> { DateTime.Now, DateTime.Now.AddDays(-1) }, "USD"))
{
Console.WriteLine(d);
}
Console.ReadKey();
}
}
}