【发布时间】:2016-11-30 17:19:47
【问题描述】:
我有一个如下所示的 xml:
<MyElement>
<Ids>
<int>1</int>
<int>2</int>
</Ids>
</MyElement>
我发现在 go 中解析很有挑战性。我已经尝试了以下
type MyElement struct {
Ids int[]
}
甚至
type Ids struct {
id int[] `xml:"int"`
}
type MyElement struct {
Ids Ids
}
但它永远不会被捡起。
困难在于元素都被称为 int 并且只存储一个 int 值,而不是通常的键/值对。
【问题讨论】: