I have the following XML from which I need to map the "DUE" and "RATE" to a list of objects with XmlSerializer. There can be zero to many, and they're always coming as a pair with the same "idx".
<INVOICE ID="4">
<STATUS>S</STATUS>
<TOTAL>6230.00</TOTAL>
<DUE idx="1">14.12.17</DUE>
<RATE idx="1">6230.00</RATE>
</INVOICE >
<INVOICE ID="5">
<STATUS>S</STATUS>
<TOTAL>3270.00</TOTAL>
<DUE idx="1">30.11.17</DUE>
<RATE idx="1">1090.00</RATE>
<DUE idx="2">07.12.17</DUE>
<RATE idx="2">1090.00</RATE>
<DUE idx="3">14.12.17</DUE>
<RATE idx="3">1090.00</RATE>
</INVOICE>
I have the following setup which is working fine without a list of "Rate" and "Due":
[Serializable]
public class UserInvoicesDto
{
[XmlElement("INVOICE")]
public List<UserInvoiceDto> Invoices { get; set; }
}
[Serializable, XmlRoot("INVOICE")]
public class UserInvoiceDto
{
[XmlAttribute("id")]
public int InvoiceId { get; set; }
[XmlElement("TOTAL")]
public string Total { get; set; }
}
And then I have the following class.
[Serializable]
public class InvoicesDueDates
{
[XmlAttribute("idx")]
public string Id { get; set; }
[XmlElement("DUE")]
public string DueDate { get; set; }
[XmlElement("RATE")]
public string Rate { get; set; }
}
Is it somehow possible?