ASP .NET example

67 views
Skip to first unread message

DGCSC XML Price Service

unread,
Oct 12, 2012, 7:05:30 AM10/12/12
to dgcsc-xml-...@googlegroups.com
Kindly donated by Brett from www.solentive.com (use freely without warranty!)

This basically writes out the prices for AUD and USD from your sample feed to a page in ASP.NET

using System.Data;
using System.IO;
using System.Xml;

        protected void ReadPriceFile()
        {
           String URLString="http://xml.dgcsc.org/samples/GoldBE.xml";

            XmlTextReader reader = new XmlTextReader(URLString);
            DataSet ds = new DataSet();
            ds.ReadXml(reader);

            double troyOzGrams = 31.1034768;

            Response.Write(ds.Tables["AUD"].Rows[0][0].ToString() + " == $" + ds.Tables["AUD"].Rows[0][1] + " AUD Per Gram");
            Response.Write("<BR/>");
            Response.Write(ds.Tables["USD"].Rows[0][0].ToString() + " == $" + ds.Tables["USD"].Rows[0][1] + " USD Per Gram");
            Response.Write("<BR/>");
            Response.Write(ds.Tables["AUD"].Rows[0][0].ToString() + " == $" + (double.Parse(ds.Tables["AUD"].Rows[0][1].ToString())*troyOzGrams).ToString("##.##") + " AUD Per Oz");
            Response.Write("<BR/>");
            Response.Write(ds.Tables["USD"].Rows[0][0].ToString() + " == $" + (double.Parse(ds.Tables["USD"].Rows[0][1].ToString()) * troyOzGrams).ToString("##.##") + " USD Per Oz");

            //foreach (DataRow row in ds.Tables[1].Rows)
            //{
            //    Response.Write(row[0].ToString());
            //}

        }

Reply all
Reply to author
Forward
0 new messages