Xml Serilization / Deserilization Array quesiton
-
I have an interface with a client that is been in production for many years, and I would like to alter the xml parsing system that handles this message. Since I may have 4 different
StatusTypes
I desire to have an array of the these items, however, they are not in a nice collection element that will make deserlization simple, like all of the examples on the internet that I could find. In the code below, I was hoping to get all of these items in MysticalList. Obviously, my example does not work ... How can I get my entity to work with a simple list?<xsd:complexType name="requestRailStatus"> <xsd:sequence> <xsd:element name="TrainID" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="BeginTimePeriod" type="xsd:dateTime" minOccurs="0" maxOccurs="1" /> <xsd:element name="EndTimePeriod" type="xsd:dateTime" minOccurs="0" maxOccurs="1" /> <xsd:element name="StatusType" type="railStatusOptions" minOccurs="0" maxOccurs="4" /> </xsd:sequence> <xsd:attribute name="timestamp" type="xsd:dateTime" use="required" /> <xsd:attribute name="messageId" type="xsd:unsignedInt" use="required" /> </xsd:complexType> <xsd:simpleType name="railStatusOptions"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="ActualTimeOfArrival" /> <xsd:enumeration value="ActualTimeOfWorking" /> <xsd:enumeration value="ActualTimeOfCompletion" /> <xsd:enumeration value="ActualTimeOfDeparture" /> </xsd:restriction> </xsd:simpleType>
public partial class requestRailStatus : EntityBase
{
public string TrainID { get; set; }
public System.DateTime BeginTimePeriod { get; set; }
public System.DateTime EndTimePeriod { get; set; }\[XmlElement("timestamp")\] public System.DateTime TimeStamp { get; set; } \[XmlElement("messageId")\] public uint MessageId { get; set; } \[XmlArray\] public List<railStatusOpti
-
I have an interface with a client that is been in production for many years, and I would like to alter the xml parsing system that handles this message. Since I may have 4 different
StatusTypes
I desire to have an array of the these items, however, they are not in a nice collection element that will make deserlization simple, like all of the examples on the internet that I could find. In the code below, I was hoping to get all of these items in MysticalList. Obviously, my example does not work ... How can I get my entity to work with a simple list?<xsd:complexType name="requestRailStatus"> <xsd:sequence> <xsd:element name="TrainID" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="BeginTimePeriod" type="xsd:dateTime" minOccurs="0" maxOccurs="1" /> <xsd:element name="EndTimePeriod" type="xsd:dateTime" minOccurs="0" maxOccurs="1" /> <xsd:element name="StatusType" type="railStatusOptions" minOccurs="0" maxOccurs="4" /> </xsd:sequence> <xsd:attribute name="timestamp" type="xsd:dateTime" use="required" /> <xsd:attribute name="messageId" type="xsd:unsignedInt" use="required" /> </xsd:complexType> <xsd:simpleType name="railStatusOptions"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="ActualTimeOfArrival" /> <xsd:enumeration value="ActualTimeOfWorking" /> <xsd:enumeration value="ActualTimeOfCompletion" /> <xsd:enumeration value="ActualTimeOfDeparture" /> </xsd:restriction> </xsd:simpleType>
public partial class requestRailStatus : EntityBase
{
public string TrainID { get; set; }
public System.DateTime BeginTimePeriod { get; set; }
public System.DateTime EndTimePeriod { get; set; }\[XmlElement("timestamp")\] public System.DateTime TimeStamp { get; set; } \[XmlElement("messageId")\] public uint MessageId { get; set; } \[XmlArray\] public List<railStatusOpti
-
You called the property StatusType, not MysticalList, in the XSD. Also, I think you mean [XmlAttribute] not [XmlElement].
If I had only "StatusType" I would agree with you, however I have 4, I want all 4 of them to be placed in the single array...
You can only be young once. But you can always be immature. - Dave Barry