package main
import (
"encoding/xml"
"fmt"
)
type Tagging struct {
XMLName xml.Name `xml:"Tagging"`
TagSet TagSet `xml:"TagSet"`
}
type TagSet struct {
XMLName xml.Name `xml:"TagSet"`
Tags []Tag `xml:"Tag"`
}
type Tag struct {
XMLName xml.Name `xml:"Tag"`
Key string `xml:"Key"`
Value string `xml:"Value"`
}
func main() {
data := `
<Tagging>
<TagSet>
<Tag>
<Key>Color</Key>
<Value>Blue</Value>
</Tag>
<Tag>
<Key>Size</Key>
<Value>Large</Value>
</Tag>
</TagSet>
</Tagging>
`
var t Tagging
xml.Unmarshal([]byte(data), &t)
fmt.Printf("Key: %s Value: %s", t.TagSet.Tags[0].Key, t.TagSet.Tags[0].Value)
fmt.Printf("Key: %s Value: %s", t.TagSet.Tags[1].Key, t.TagSet.Tags[1].Value)
}
To embed this program on your website, copy the following code and paste it into your website's HTML: