So, I'm trying a Unmarshal XML file generated as a save file by another program in Google Go. This seems like good, as the documentation on this is quite extensive: http://golang.org/pkg/encoding/xml/#Unmarshal
Still, I have a problem. The result in the save file is as follows:
<location id="id4" x="-736" y="-544">
<committed />
</location>
Instead of a fixed location, it may be urgent or not. Places may also have a name and different labels, but they seem to be well-understood. In my Go code, I use the following structure:
type Location struct {
Id string `xml:"id,attr"`
Committed bool `xml:"commited"`
Urgent bool `xml:"urgent"`
Labels []Label `xml:"label"`
}
And although the Unmarshal function of the encoding / xml package works without errors, and the example shown is present in the data, all values โโof both fixed and urgent are "false".
, ?
(Unmarshalling )
xmlFile, err := os.Open("model.xml")
if err != nil {
fmt.Println("Error opening file:", err)
return
}
defer xmlFile.Close()
b, _ := ioutil.ReadAll(xmlFile)
var xmlScheme uppaal.UppaalXML
err = xml.Unmarshal(b, &xmlScheme)
fmt.Println(err)