CSharp examples for System.Xml:XML Attribute
Get As Date Time from XAttribute
using System.Xml.Linq; using System;/*w ww . j a v a 2s .c om*/ public class Main{ #endregion #region GetAsDateTime Method public static DateTime GetAsDateTime(this XAttribute attr) { DateTime ret = default(DateTime); DateTime value = default(DateTime); if (attr != null && !string.IsNullOrEmpty(attr.Value)) { if (DateTime.TryParse(attr.Value, out value)) ret = value; } return ret; } }