Cast the value of this XAttribute to a DateTime.
using System; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{ public static void Main(){ XElement root = new XElement("Root", new XAttribute("Att", new DateTime(2010, 10, 6, 12, 30, 0)) ); Console.WriteLine(root); DateTime dt = (DateTime)root.Attribute("Att"); Console.WriteLine("dt={0}", dt); XAttribute dtAtt = new XAttribute("OrderDate", "October 6, 2006"); Console.WriteLine(dtAtt); DateTime orderDate = (DateTime)dtAtt; Console.WriteLine("OrderDate={0:d}", orderDate); } }