I want to make a sample xml that repeats a field depending on the value of the slice. But the final result is not as desired.
XML that I want to create
recipients = ["num1","num2",...]
//Start XML
.
.
.
<SendDetail>
<item><Mobile>num1</Mobile></item>
<item><Mobile>num2</Mobile></item>
...
</SendDetail>
The number of repetitions of depends on the length of the slice of recipients and its values.
My Code
type item struct {
Mobile []string `xml:"Mobile"`
}
type sendDetail struct {
Item *[]item `xml:"item"`
}
SendDetail: &sendDetail{
Item:&[]item{
item{
Mobile:recipients,
},
},
},
Result
<SendDetail>
<item>
<Mobile>num1</Mobile>
<Mobile>num2</Mobile>
</item>
</SendDetail>
Any pointers will be appreciated.