Quantcast
Channel: Go XML Unmarshaling not reading attribute - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Go XML Unmarshaling not reading attribute

$
0
0

New to Go lang. From the XML, the code unmarshall all values except for attribute. Can someone please advise what I am doing wrong:

package mainimport ("encoding/xml""fmt")func main() {    v, _ := GetData()    fmt.Print(v)}type Query struct {    InstituationList []Instituation `xml:"institution"`}type Instituation struct {    XMLName           xml.Name `xml:"institution"`    OFXHomeID         string   `xml:"id, attr"`    Name              string   `xml:"name"`    FId               string   `xml:"fid"`    FOrg              string   `xml:"org"`    URL               string   `xml:"url"`    OFXHomeIDD         string   `xml:"idd"`}func GetData() (*Query, error) {    fakeXML := `<?xml version="1.0" encoding="utf-8"?><Data><institution id="A421"><idd>423</idd><name>ING DIRECT (Canada)</name><fid>061400152</fid><org>INGDirectCanada</org><url>https://ofx.ingdirect.ca</url></institution></Data>`    content := []byte(fakeXML)    e := new(Query)    xml.Unmarshal(content, e)    return e, nil}

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images