Select Single XML Text Date Time - CSharp System.Xml

CSharp examples for System.Xml:XPath

Description

Select Single XML Text Date Time

Demo Code


using System.Xml;
using System;//from ww w . j a v a 2s.co m

public class Main{
        public static DateTime? SelectSingleTextDateTime(XmlNode node, string selector, DateTime? defaultValue = null)
    {
        workNode = node.SelectSingleNode(selector, Manager);
        if (workNode != null && DateTime.TryParse(workNode.InnerText, out dtTryParse))
        {
            return dtTryParse;
        }

        return defaultValue;
    }
}

Related Tutorials