我试图解组以下XML,但收到错误。
<ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<Items>
<Item>
<ASIN>B005XSS8VC</ASIN>
</Item>
</Items>
这是我的结构:
type Product struct {
XMLName xml.Name `xml:"Item"`
ASIN string
}
type Result struct {
XMLName xml.Name `xml:"ItemSearchResponse"`
Products []Product `xml:"Items"`
}
错误的文本是“期望的元素类型,<Item>但是有<Items>”,但是我看不到哪里出错了。任何帮助表示赞赏。
v := &Result{Products: nil}
err = xml.Unmarshal(xmlBody, v)
相关分类