Fixes MarshalXML() and renames initial "H" tag to "map".

This commit is contained in:
Manu Mtz-Almeida 2014-07-06 18:25:17 +02:00
parent c9809ab10d
commit f8d85c1b4d

5
gin.go
View File

@ -83,6 +83,7 @@ var (
// Allows type H to be used with xml.Marshal // Allows type H to be used with xml.Marshal
func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error { func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Name = xml.Name{"", "map"}
if err := e.EncodeToken(start); err != nil { if err := e.EncodeToken(start); err != nil {
return err return err
} }
@ -91,11 +92,11 @@ func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
xml.Name{"", key}, xml.Name{"", key},
[]xml.Attr{}, []xml.Attr{},
} }
if err = e.EncodeElement(value, elem); err != nil { if err := e.EncodeElement(value, elem); err != nil {
return err return err
} }
} }
if err = e.EncodeToken(xml.EndElement{start.Name}); err != nil { if err := e.EncodeToken(xml.EndElement{start.Name}); err != nil {
return err return err
} }
return nil return nil