using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Net;using System.Xml.Linq;namespace ECBBank{ public partial class _Default : System.Web.UI.Page { private string xmlData; protected void Page_Load(object sender, EventArgs e) { WebClient client = new WebClient(); xmlData = client.DownloadString("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); XElement element = XElement.Parse(xmlData); XNamespace ns = "http://www.ecb.int/vocabulary/2002-08-01/eurofxref"; IEnumerable data = from c in element.Elements(ns + "Cube").Elements(ns + "Cube").Elements(ns + "Cube") select c; List lstdata = (from c in element.Elements(ns + "Cube").Elements(ns + "Cube").Elements(ns + "Cube") select new CubeData() { Currency = c.Attribute("currency").Value, Rate = c.Attribute("rate").Value }).ToList(); GridView1.DataSource = lstdata; GridView1.DataBind(); } }}
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ECBBank._Default" %>< asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> asp:Content>< asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> < center> < h2> Welcome to ECB Rate Chart < /h2> < br /> < asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" AutoGenerateColumns="false" AllowSorting="false"> < AlternatingRowStyle BackColor="#F7F7F7" /> < FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> < HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> < PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> < RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> < SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> < SortedAscendingCellStyle BackColor="#F4F4FD" /> < SortedAscendingHeaderStyle BackColor="#5A4C9D" /> < SortedDescendingCellStyle BackColor="#D8D8F0" /> < SortedDescendingHeaderStyle BackColor="#3E3277" /> < Columns> < asp:TemplateField> < HeaderTemplate> < asp:Literal ID="header" Text="ID" runat="server"> asp:Literal> < /HeaderTemplate> < ItemTemplate> < asp:Literal ID="id" Text='<%#Container.DataItemIndex + 1%>' runat="server"> asp:Literal> < /ItemTemplate> < /asp:TemplateField> < asp:BoundField DataField="Currency" HeaderText="Currency" SortExpression="Currency"/> < asp:BoundField DataField="Rate" HeaderText="Rate" /> < /Columns> < /asp:GridView>< /asp:Content>
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace ECBBank{ public class CubeData { private string fileLocaion = "hello"; public int ID { get; set; } public string Currency { get; set; } public string Rate { get; set; } }}