Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Golang Unmarshal XML attributes

Tags:

xml

go

I'm trying to get some attribute values out of XML, but without success. http://play.golang.org/p/a5IqjbH3DV

Can anyone spot of what I'm doing wrong?

like image 326
if __name__ is None Avatar asked Oct 28 '25 18:10

if __name__ is None


1 Answers

The fields should be exported ( start with uppercase )

You did it right for the Entry but not for the Statistics struct

See: http://play.golang.org/p/cQRGJag313

type Statistics struct {
    TotalUploadViews int `xml:"totalUploadViews,attr"`
    SubscriberCount  int `xml:"subscriberCount,attr"`
}
like image 153
OscarRyz Avatar answered Oct 31 '25 08:10

OscarRyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!