The program I'm exporting XML for seems to want the xml tags to be in a specific order like the example below
<xml>
<tagType1>data 1</tagType1>
<tagType2>data 2</tagType2>
<tagType1>data 3</tagType1>
<tagType2>data 4</tagType2>
</xml>
In go, I marshal into a struct like below
type xml struct {
TagType1 []string `xml:"tagType1"`
TagType2 []string `xml:"tagType2"`
}
When I marshal that back out, it sorts the tags which is expected, but that is not what I need.
<xml>
<tagType1>data 1</tagType1>
<tagType1>data 3</tagType1>
<tagType2>data 2</tagType2>
<tagType2>data 4</tagType2>
</xml>
Is there a way with the encoding/xml package to reproduce the output in the first example? The order varies. I read an xml file with specific orders, modify the data and marshal that back out. I need the tag order to be kept.