Hello, I have faced a problem about creating a go struct that when unmarshalled can match the below xml structure. The problem is in PAYMENTS
part. Say payment struct has a field named PMTTYPE
and PMTAMOUNT
how can you unmarshal a list of PAYMENTS and have them nested like below without creating a nested structure.
<TOTALS>
<TOTALTAXEXCL>169.49</TOTALTAXEXCL>
<!-- Total of all the items exclusive of Tax-->
<TOTALTAXINCL>200</TOTALTAXINCL>
<!-- Total of all the items inclusive of Tax-->
<DISCOUNT>0.00</DISCOUNT>
</TOTALS>
<PAYMENTS>
<PMTTYPE>CASH</PMTTYPE>
<!-- Mode of Payment can either be CASH, CHEQUE, EMONEY or CCARD if receipt is generated. In this case payment is already received-->
<PMTAMOUNT>200.00</PMTAMOUNT>
<!-- Payment amount-->
<PMTTYPE>INVOICE</PMTTYPE>
<!-- Mode of Payment can only be INVOICE if invoice is generated. In this case payment is not yet received that is why we use Invoice -->
<PMTAMOUNT>200.00</PMTAMOUNT>
<!-- Payment amount-->
</PAYMENTS>
<VATTOTALS>
<VATRATE>A</VATRATE>
<!-- Tax group applicable on the items for VAT items should A and for no VAT items should be C-->
<NETTAMOUNT>169.49</NETTAMOUNT>
<!-- Total of all the items exclusive of Tax-->
<TAXAMOUNT>30.51</TAXAMOUNT>
<!-- Tax amount paid-->
</VATTOTALS>