Please see this playground: https://play.golang.org/p/FOMWqhjdneg
As you can see I have a XML response which I want to unmarshal into a Product
struct. The XML has an "assetBlock"
which contains nested nodes and extract data to Product struct. Any help would be appreciated
从XML创建结构
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dtfbj24048 2018-02-23 11:29关注
You need to make a struct for
AssetBlock
and all of the types below it, I've done it up togroup
to show you what I mean:https://play.golang.org/p/vj_CkneHuLd
type Product struct { GlobalID string `xml:"globalId"` Title string `xml:"title"` ChunkID int `xml:"gpcChunkId"` AssetBlock assetBlock `xml:"assetBlock"` } type assetBlock struct { Images images `xml:"images"` } type images struct { GroupList groupList `xml:"groupList"` } type groupList struct { Groups []group `xml:"group"` } type group struct { Usage string `xml:"usage"` Size string `xml:"size"` }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀
- ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
- ¥15 关于#hadoop#的问题
- ¥15 (标签-Python|关键词-socket)
- ¥15 keil里为什么main.c定义的函数在it.c调用不了
- ¥50 切换TabTip键盘的输入法