I understand how to unmarshal simple xml data to Go structs but can't figure out how to handle dynamic tags. Here's an example. There can be <image_3><image_4>
etc
<?xml version="1.0" encoding="utf-8"?>
<products>
<product>
<product_id>11600</product_id>
<date_created><![CDATA[2018-10-19 15:20:22]]></date_created>
<price>200</price>
<stock_status>In Stock</stock_status>
<images>
<image_1>1.jpg</image_1>
<image_2>2.jpg</image_2>
</images
</product>
</products>
//update
type Products struct {
XMLName xml.Name `xml:"products"`
Text string `xml:",chardata"`
Product struct {
Text string `xml:",chardata"`
ProductID string `xml:"product_id"`
DateCreated string `xml:"date_created"`
Price string `xml:"price"`
StockStatus string `xml:"stock_status"`
Images map[string]string `xml:"images"`
} `xml:"product"`
}
When I run fmt.Println(len(products.Product[0].Images))
I get 0. What I'm missing here?