using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
namespace XMLApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[XmlRoot(ElementName = "Sender", Namespace = "http://www.gesmes.org/xml/2002-08-01")]
public class Sender
{
[XmlElement(ElementName = "name", Namespace = "http://www.gesmes.org/xml/2002-08-01")]
public string Name { get; set; }
}
[XmlRoot(ElementName = "Cube", Namespace = "http://www.ecb.int/vocabulary/2002-08-01/eurofxref")]
public class Cube
{
[XmlAttribute(AttributeName = "currency")]
public string Currency { get; set; }
[XmlAttribute(AttributeName = "rate")]
public string Rate { get; set; }
}
[XmlRoot(ElementName = "Envelope", Namespace = "http://www.gesmes.org/xml/2002-08-01")]
public class Envelope
{
[XmlElement(ElementName = "subject", Namespace = "http://www.gesmes.org/xml/2002-08-01")]
public string Subject { get; set; }
[XmlElement(ElementName = "Sender", Namespace = "http://www.gesmes.org/xml/2002-08-01")]
public Sender Sender { get; set; }
[XmlElement(ElementName = "Cube", Namespace = "http://www.ecb.int/vocabulary/2002-08-01/eurofxref")]
public Cube Cube { get; set; }
[XmlAttribute(AttributeName = "gesmes", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Gesmes { get; set; }
[XmlAttribute(AttributeName = "xmlns")]
public string Xmlns { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
string conString;
conString = "";
string Value;
Value = "";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
foreach (XmlNode xmlNode in xmlDoc.DocumentElement.ChildNodes[2].ChildNodes[0].ChildNodes)
conString = conString + xmlNode.Attributes["currency"].Value + ": " + xmlNode.Attributes["rate"].Value + "\r\n";
textBox1.Text = conString;
textBox2.Text = xmlDoc.DocumentElement.LocalName;
}
}
}