.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> XML >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Code to Create Own Currency Convertor

Posted By:Lakhan Pal Garg       Posted Date: September 12, 2009    Points: 10    Category: XML    URL: http://www.dotnetspark.com  

XML Based Currency Converter

Sample Code:

using System.Xml;
private void ReadXMLData(string SourceCountry, string DestCountry)
double Amount = 10;
string SourceCode = "";
double SourceCountryValue=0;
double DestCountryValue=0;
string DestCode = "";
XmlDocument xmlDoc = new XmlDocument();
XmlNodeList xmlList= xmlDoc.GetElementsByTagName("Country");
for (Int16 iCount = 0; iCount <>
if (xmlList.Item(iCount).Attributes.GetNamedItem("name").InnerText == SourceCountry)
SourceCountryValue = Convert.ToDouble(xmlList.Item(iCount).Attributes.GetNamedItem("value").InnerText);
SourceCode = xmlList.Item(iCount).Attributes.GetNamedItem("CurrencyCode").InnerText;
else if (xmlList.Item(iCount).Attributes.GetNamedItem("name").InnerText == DestCountry)
DestCountryValue = Convert.ToDouble(xmlList.Item(iCount).Attributes.GetNamedItem("value").InnerText);
DestCode = xmlList.Item(iCount).Attributes.GetNamedItem("CurrencyCode").InnerText;
Response.Write(Amount.ToString()+ " "+SourceCode +"=" +Convert.ToString(Amount * (DestCountryValue / SourceCountryValue)));
Call the above Method Like This: ReadXMLData("UK", "India");


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend