Golang XML Parsen

Meine XML-Daten:

<dictionary version="0.8" revision="403605">
    <grammemes>
        <grammeme parent="">POST</grammeme>
        <grammeme parent="POST">NOUN</grammeme>
    </grammemes>
</dictionary>

Mein code:

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"`
}

Bekomme ich Grammeme.Parent-Attribut, aber ich bekomme nicht Grammeme.Name. Warum?

InformationsquelleAutor Kroid | 2014-03-26
Schreibe einen Kommentar