You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there
I am trying to access attributes of nested XML elements. The first element's attributes
are stored fine, but subsequent elements get missed. From the attached file, both
attributes of the "Tournament" element get stored, however any subsequent
elements like "Match" do not.
I have tried several ways to fix this:
type Tournament struct {
BetradarTournamentId int `xml:",attr"` //This works
UniqueTournamentId int `xml:",attr"` //This works
Name string `xml:"Name"`
Match []Match `xml:"Match"`
}
type Match struct {
BetradarMatchId int `xml: ",attr"` //This doesnt work
previouslegmatchid []xml.Attr `xml: ",attr"` //This doesnt work
Id int `xml: "Id,attr"` //This doesnt work
...
}
There seems to be a bug related to this -
https://golang.org/issue/3633
Is there any way I can store these attributes correctly? I am running Go v1.1.
Thanks in advance
http://play.golang.org/p/8LJYerWMOm seems to work.
There are two problems with the snippet you posted. One is that you have a space between
the : and " in `xml: ",attr"` in a few of the places. The other is that
previouslegmatchid is unexported.
by kyle@onnet.co.za:
Attachments:
The text was updated successfully, but these errors were encountered: