I'm trying to create an xml file with the following ordering using the encoding/xml package and i have defined structs for the static subelement and transition subelement, now the problem is i need to to have this in a repeating format so i created another struct to hold slices of both static and transition structs but the result is the static elements all appear before the transition element but i need them to alternate in order. This is the structure i want:
<background>
//...
<static>
<duration></duration>
<file></file>
</static>
<transition>
<duration>
<from></from>
<to></to>
</transition>
<static>
<duration></duration>
<file></file>
</static>
<transition>
<duration>
<from></from>
<to></to>
</transition>
//...
</background>
but this is what i get:
<background>
//...
<static>
<duration></duration>
<file></file>
</static>
<static>
<duration></duration>
<file></file>
</static>
<transition>
<duration>
<from></from>
<to></to>
</transition>
<transition>
<duration>
<from></from>
<to></to>
</transition>
//...
</background>
Any help as to how i could do it. These are the structs i have created:
type Static struct {
Duration int `xml:"duration"`
File string `xml:"file"`
}
type Transition struct {
Duration float64 `xml:"duration"`
From string `xml:"from"`
To string `xml:"to"`
}
type ST struct {
Static []Static `xml:"static"`
Transition []Transition `xml:"transition"`
}
type Background struct {
XMLName xml.Name `xml:"background"`
Comment string `xml:",comment"`
ST
}