String xml = new WebClient().DownloadString(@"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
XDocument doc = XDocument.Parse(xml);
DataTable dt = new DataTable();
dt.Columns.Add("Moneda", typeof(string));
dt.Columns.Add("Valor", typeof(float));
foreach (XElement element in doc.Descendants())
{
if (!String.IsNullOrEmpty((String)element.Attribute("currency")))
{
String moneda = element.Attribute("currency").Value;
dt.Rows.Add(moneda, element.Attribute("rate").Value.ToStrim().Replace(".", ","));
}
}
Snippet to read a downloaded xml
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.