CSharp examples for System.Xml:XML Attribute
Select Single XML Attribute Date Time
using System.Xml; using System;//from w w w . j a va 2 s. co m public class Main{ public static DateTime? SelectSingleAttributeDateTime(XmlNode node, string name, DateTime? defaultValue = null) { if (node?.Attributes == null) { return defaultValue; } workAttr = node.Attributes[name]; if (workAttr != null && DateTime.TryParse(workAttr.Value, out dtTryParse)) { return dtTryParse; } return defaultValue; } }