Tuesday, September 03, 2013

Currency Converter via XML web service


//add webservice http://www.webservicex.net/country.asmx
WebServiceX.country client = new WebServiceX.country();
var currencies = client.GetCurrencies();

//Convert the XML result into dataset/table
DataSet ds = new DataSet();
ds.ReadXml(new System.Xml.XmlTextReader(new StringReader(currencies)));

string name = null;
string code = null;

//name & country code.
foreach (DataRow r in ds.Tables[0].Rows)
{
    name = r["Name"].ToString();
    code = r["CountryCode"].ToString();

    Console.WriteLine(name + " " + code);
}

No comments: