How to deserialize "<MyType><StartDate>01/01/2000</StartDate></MyType>"

Posted by afin on Stack Overflow See other posts from Stack Overflow or by afin
Published on 2010-04-21T16:02:18Z Indexed on 2010/04/21 17:43 UTC
Read the original article Hit count: 604

How to deserialize "<MyType><StartDate>01/01/2000</StartDate></MyType>"

below is the MyType definition

[Serializable]
public class MyType
{
    DateTime _StartDate;
    public DateTime StartDate
    {
        set
        {
            _StartDate = value;
        }
        get
        {
            return _StartDate;
        }
    }
}

Got the following error while deserializing

{"The string '01/01/2000' is not a valid AllXsd value."} [System.FormatException]: {"The string '01/01/2000' is not a valid AllXsd value."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: null Message: "The string '01/01/2000' is not a valid AllXsd value." Source: "System.Xml" StackTrace: " at System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds)\r\n at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)\r\n at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)\r\n at System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value)\r\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMyType.Read2_MyType(Boolean isNullable, Boolean checkType)\r\n
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMyType.Read3_MyType()" TargetSite: {Void .ctor(System.String, System.Xml.Schema.XsdDateTimeFlags)}

© Stack Overflow or respective owner

Related posts about c#

Related posts about serialization