encoding/xml
Work with XML.
Working with XML
XML is a verbose, tag-based format still common in legacy systems and configs. Go's encoding/xml package marshals and unmarshals it, mirroring the json package.
Marshal to XML
xml.Marshal turns a Go value into XML bytes.
package main
import (
"encoding/xml"
"fmt"
)
type User struct {
Name string
Age int
}
func main() {
b, _ := xml.Marshal(User{"Ann", 30})
fmt.Println(string(b))
}