Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Xml Serilization / Deserilization Array quesiton

Xml Serilization / Deserilization Array quesiton

Scheduled Pinned Locked Moved C#
questiondata-structuresxmljsontutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason McBurney
    wrote on last edited by
    #1

    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
    
    B 1 Reply Last reply
    0
    • J Jason McBurney

      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
      
      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      You called the property StatusType, not MysticalList, in the XSD. Also, I think you mean [XmlAttribute] not [XmlElement].

      J 1 Reply Last reply
      0
      • B BobJanova

        You called the property StatusType, not MysticalList, in the XSD. Also, I think you mean [XmlAttribute] not [XmlElement].

        J Offline
        J Offline
        Jason McBurney
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups