Get Decimal from XmlElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get Decimal from XmlElement

Demo Code


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

public class Main{
        public static decimal GetDecimal(XmlElement source, string childName)
        {
            string txt = GetText(source, childName);
            return string.IsNullOrEmpty(txt) ? 0M : decimal.Parse(txt);
        }
        public static decimal GetDecimal(XmlElement source, string childName, IFormatProvider formatProvider)
        {
            string txt = GetText(source, childName);
            return string.IsNullOrEmpty(txt) ? 0M : decimal.Parse(txt, formatProvider);
        }
}

Related Tutorials