Mega Code Archive

 
Categories / C# / XML
 

XmlReader ReadElementContentAsDateTime reads the element and returns the contents as a DateTime object

using System; using System.IO; using System.Xml; public class Sample {     public static void Main()     {         using (XmlReader reader = XmlReader.Create("dataFile.xml"))         {             reader.ReadToFollowing("date");             DateTime date = reader.ReadElementContentAsDateTime();             Console.WriteLine(date.ToLongDateString());         }     } }