I have a xml stored in db which i am unmarshalling using xml.unmarshall in GO with the struct I defined. When getting the API response I am not getting the XML header and also the namespace.
type Entity struct {
XMLName xml.Name `xml:"entity" json:"-"`
etc..
}
while sending response
func get(c *gin.Context) {
...
entity=new(model.Entity)
offeredContentTypes := []string{"application/xml", "application/json"}
c.Negotiate(http.StatusOK, gin.Negotiate{
Offered: offeredContentTypes,
XMLData: entity,
JSONData: entity,
})
}
the xml entity I have in db has the required header as well as namespace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><entity xmlns:ns2="http://abc/xyz">....</entity>
this is the type of response I get
<entity>...</entity>
How can I fix this so that i get both xml header as well as namespace??