Is there a way to unmarshal XML tags with dynamic attributes (I don't know which attributes I'll get every time).
Maybe it's not supported yet. See Issue 3633: encoding/xml: support for collecting all attributes
Something like :
package main
import (
"encoding/xml"
"fmt"
)
func main() {
var v struct {
Attributes []xml.Attr `xml:",any"`
}
data := `<TAG ATTR1="VALUE1" ATTR2="VALUE2" />`
err := xml.Unmarshal([]byte(data), &v)
if err != nil {
panic(err)
}
fmt.Println(v)
}