Get Double from XmlElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get Double from XmlElement

Demo Code


using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;/*from ww w. ja  va  2  s.co  m*/

public class Main{
        public static double GetDouble(XmlElement source, string childName)
        {
            string txt = GetText(source, childName);
            return string.IsNullOrEmpty(txt) ? 0.0 : double.Parse(txt);
        }
        public static double GetDouble(XmlElement source, string childName, IFormatProvider formatProvider)
        {
            string txt = GetText(source, childName);
            return string.IsNullOrEmpty(txt) ? 0.0 : double.Parse(txt, formatProvider);
        }
}

Related Tutorials