Mega Code Archive

 
Categories / C# Tutorial / XML
 

Read XML content as double

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Xml;     public class MainClass     {         public static void Main()         {             XmlReader reader;             double totalPrice=0;                          reader = XmlReader.Create("pubs.xml");             while (reader.Read())             {                 if (reader.IsStartElement() && reader.Name=="titles")                 {                     reader.MoveToAttribute("price");                     totalPrice += reader.ReadContentAsDouble();                 }             }         }     }