This is my sample XML:
<outbound>
<leg0 Code="aaa" RetCode="ccc"/>
<leg1 Code="bbb" RetCode="ddd"/>
</outbound>
Is it possible to use somehow XmlElement (I'm using XmlSerializer) to deserialize leg0 and leg1 to one object type?
My object's looks like that:
public class FlightInfo
{
[XmlElement(ElementName = "outbound")]
public Outbound Outbound { get; set; }
}
public class Outbound
{
[XmlElement(ElementName = "leg")]
public List<Leg> Leg { get; set; }
}
public class Leg
{
[XmlAttribute(AttributeName = "Code")]
public string Code{ get; set; }
[XmlAttribute(AttributeName = "RetCode")]
public string ReturnCode{ get; set; }
}
My problem is to deserialize elements leg0 and leg1 to Leg object. Can anybody give my a hint?