Go语言开发中API 返回Xml数据实例

GO交流群:874512552

//返回xml
type  xmlIp struct {
   XmlList []xmlList
}
type xmlList struct {
   Ip string `xml:"ip"`
   Port string `xml:"port"`
   Country string `xml:"country"`
   City string `xml:"city"`
}
//xml
xmlIp := &xmlIp{}
xmlIp.XmlList=append(xmlIp.XmlList,xmlList{
   Ip:"127.0.0.1",
   Port:"3306",
   Country:"正在",
   City:"aaaaa",
})
xmlIp.XmlList=append(xmlIp.XmlList,xmlList{
 Ip:"127.0.0.1",
 Port:"3306",
 Country:"正在",
 City:"aaaaa",
})
xmlIp.XmlList=append(xmlIp.XmlList,xmlList{
 Ip:"127.0.0.1",
 Port:"3306",
 Country:"正在",
 City:"aaaaa",
})
this.Data["xml"]=xmlIp
this.ServeXML()

用于beego框架

详情:https://www.jianshu.com/p/28f57095fb14

你可能感兴趣的:(go)