The string '3/18/09 10:16 PM' is not a valid AllXsd value
According to the XML schema spec, date time values should be in ISO8601 format, e.g., something like
2009-03-13T22:16:00
Xml readers generally expect dates/times in a very specific format; you can use this yourself using XmlConvert
:
string s = XmlConvert.ToString(DateTime.Now);
DateTime when = XmlConvert.ToDateTime(s);
If you are using something else, you'll have to read it as a string and use DateTime.TryParseExact
(or similar) to specify the actual format string:
string s = reader.ReadContentAsString();
DateTime when = DateTime.ParseExact(s, "M/d/yy hh:mm tt",
CultureInfo.InvariantCulture);
If you are using XmlSerializer
, you could use a shim property to do the conversion - let me know if this is what you are doing...