Get Date Time from XmlElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get Date Time from XmlElement

Demo Code


using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;//from  ww w . java2  s  .c o m

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

Related Tutorials