1 回答
TA贡献1811条经验 获得超6个赞
您如何看待这样重写您的代码(https://play.golang.org/p/Kf5VpQeuThx):
package main
import (
"encoding/xml"
"fmt"
"os"
)
type s2 struct {
XMLName xml.Name `xml:"q3:WMLS_AddToStore"`
XMLAttr string `xml:"xmlns:q3,attr"`
WMLtypeIn string `xml:"WMLtypeIn,omitempty" json:"WMLtypeIn,omitempty" yaml:"WMLtypeIn,omitempty"`
XMLin string `xml:"XMLin,omitempty" json:"XMLin,omitempty" yaml:"XMLin,omitempty"`
OptionsIn string `xml:"OptionsIn,omitempty" json:"OptionsIn,omitempty" yaml:"OptionsIn,omitempty"`
CapabilitiesIn string `xml:"CapabilitiesIn,omitempty" json:"CapabilitiesIn,omitempty" yaml:"CapabilitiesIn,omitempty"`
}
type s1 struct {
XMLName xml.Name `xml:"SOAP-ENV:Body"`
S2 s2
}
func main() {
x := &s1{
S2: s2{
XMLAttr: "http://www.foo.abr/message/120",
WMLtypeIn: "WMLtypeIn",
XMLin: "XMLin",
OptionsIn: "OptionsIn",
CapabilitiesIn: "CapabilitiesIn",
},
}
enc := xml.NewEncoder(os.Stdout)
enc.Indent("", " ")
if err := enc.Encode(x); err != nil {
fmt.Printf("error: %v\n", err)
}
}
- 1 回答
- 0 关注
- 97 浏览
添加回答
举报