using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Linq;
public static class XmlUtility
{
public static DateTime? GetValueAsDateTime(this XElement element, IFormatProvider formatProvider)
{
Debug.Assert(formatProvider != null, "formatProvider is null.");
if (String.IsNullOrEmpty(element.Value) == false)
{
DateTime dateTime;
if (DateTime.TryParse(element.Value, formatProvider, DateTimeStyles.None, out dateTime))
{
return dateTime;
}
}
return null;
}
public static DateTime? GetValueAsDateTime(this XAttribute attribute, IFormatProvider formatProvider)
{
if (String.IsNullOrEmpty(attribute.Value) == false)
{
DateTime dateTime;
if (DateTime.TryParse(attribute.Value, formatProvider, DateTimeStyles.None, out dateTime))
{
return dateTime;
}
}
return null;
}
}