Ich habe Probleme unmarshalling die XML unten, wie finde ich alle <info>
Knoten mit type="Genres"
und speichern ihre Werte innerhalb eines []Genre
?XML-Unmarshalling mit Go: Wie finde ich Attribute mit dem gleichen Wert?
<manga id="4199" type="manga" name="Jinki: Extend" precision="manga">
<info type="Main title" lang="EN">Jinki: Extend</info>
<info type="Genres">action</info>
<info type="Genres">science fiction</info>
<info type="Themes">mecha</info>
<info type="Number of tankoubon">9</info>
<info type="Number of pages">186</info>
</manga>
Ich suche die Werte in structs ähnlich wie diese speichern:
// Manga struct
type Manga struct {
WorkID int `xml:"id,attr"`
Name string `xml:"name,attr"`
Precision string `xml:"precision,attr"`
Genres []Genre `[this is the part I need help on]`
}
// Genre struct
type Genre struct {
Value string
}
Ich weiß, dass das XML ist nicht ideal, aber es ist, was ich habe, mit zu arbeiten, ich hoffe, euch kann mir dabei helfen.
Vielen Dank im Voraus.