encoding/xml , , , Foo , <bar>, . , xml.Unmarshal :
main.Foo "Bar1" " " Bar2 " " "
, :
1. Bar
:
type Foo struct {
XMLName xml.Name `xml:"foo"`
Bars []Bar `xml:"bar"`
}
type Bar struct {
Zip string `xml:"zip"`
Zap string `xml:"zap"`
}
, <bar>. , <zip> <zap>, , .
: https://play.golang.org/p/kguPCYmKX0
2.
<bar> , , . , :
type Foo struct {
XMLName xml.Name `xml:"foo"`
Zip string `xml:"bar>zip"`
Zap string `xml:"bar>zap"`
}
<bar> Foo. , , ,
<foo>
<bar>
<zip>zip</zip>
<zap>zap</zap>
</bar>
</foo>
, .
: https://play.golang.org/p/fAE_HSrv4y