8
我的XML數據:Golang XML解析
<dictionary version="0.8" revision="403605">
<grammemes>
<grammeme parent="">POST</grammeme>
<grammeme parent="POST">NOUN</grammeme>
</grammemes>
</dictionary>
我的代碼:
type Dictionary struct {
XMLName xml.Name `xml:"dictionary"`
Grammemes *Grammemes `xml:"grammemes"`
}
type Grammemes struct {
Grammemes []*Grammeme `xml:"grammeme"`
}
type Grammeme struct {
Name string `xml:"grammeme"`
Parent string `xml:"parent,attr"`
}
我得到Grammeme.Parent屬性,但我不明白Grammeme.Name。爲什麼?