0

I need to deserialize a XML to an object, and i don't know how to convert a list of string in the XML to a list of object in the class.

I have this XML:

<Rack>
<Code>Code1</Code>
<SlotDtl>
  <Serial>010</Serial>
  <Serial>011</Serial>
  <Serial>012</Serial>
  <Serial>013</Serial>
</SlotDtl>....

And i need to create a list of Class slot:

[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public class Rack
{

    public string Code;

    [System.Xml.Serialization.XmlElementAttribute("SlotDtl", typeof(Slot))]
    public List<Slot> SlotList;
}

[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public class Slot
{
    public string Serial;
    public int Value;
    public int Record;
    public string Description;
}

But i don't know how to créate the list of object with the serialization tags.

Any Idea?

sishco
  • 11
  • 4
  • How do you want to bind `010` to your `Slot` object? What will the `010` value be mapped to, and what should the other values be? – dbc Jan 13 '17 at 22:55
  • This might be a duplicate of [Using XmlSerializer to create an element with attributes and a value but no sub-element](http://stackoverflow.com/a/3524289/3744182) but I can't say for certain unless you explain how you want to bind the `Slot` class to the `010` elements. – dbc Jan 14 '17 at 22:57

0 Answers0