I have some XML that I am trying serialize like so:
string Value = @"<MSG>
<ABCID>
<ID>0123456789A</ID>
<ID>0123456790B</ID>
</ABCID>
<DATETIME>2010-01-07T13:00:09</DATETIME>
</MSG>";
try
{
XmlMsg Msg = (XmlMsg)new XmlSerializer(typeof(XmlMsg)).Deserialize(new System.IO.StringReader(Value));
}
catch (System.Exception ex)
{
}
Normally I only receive one ID in the ABCID node so its ok however a new requirement needs more than one ID so when I serialize it I want to see all ID's, at the moment it just shows the first ID.
This is my serializing class:
[XmlRoot("MSG")]
public class XmlMsg
{
[XmlElement("ABCID", IsNullable = true)]
public SubNodes AbcId { get; set; }
[XmlElement("DATETIME", IsNullable = true)]
public string DateTime { get; set; }
}
public class SubNodes
{
[XmlElement("ID", IsNullable = true)]
public string Id { get; set; }
}