dsxd62219570 2013-09-06 16:50
浏览 199
已采纳

Golang Unmarshal XML属性

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?

  • 写回答

1条回答 默认 最新

  • dongqiang5865 2013-09-06 16:57
    关注

    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"`
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?