go xml 序列化
/**
序列化
*/
package main
import (
"encoding/xml"
"fmt"
)
// Person 结构
type Person struct {
Name string `xml:"name,attr"`
Age int
}
// 入口
func main() {
ctj := Person{"chentingjun", 27}
if data, err := xml.MarshalIndent(ctj, "", " "); err != nil {
fmt.Println(err)
} else {
fmt.Println("serialization data =>\n", string(data))
}
}