added error handling
This commit is contained in:
parent
3c2da97919
commit
c978efa42f
19
gin.go
19
gin.go
@ -64,12 +64,21 @@ type (
|
||||
|
||||
// Allows type H to be used with xml.Marshal
|
||||
func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||
e.EncodeToken(start)
|
||||
for key, value := range h {
|
||||
elem := xml.StartElement{Name: xml.Name{Local: key}}
|
||||
e.EncodeElement(value, elem)
|
||||
if err := e.EncodeToken(start); err != nil {
|
||||
return err
|
||||
}
|
||||
for key, value := range h {
|
||||
elem := xml.StartElement{
|
||||
xml.Name{"", key},
|
||||
[]xml.Attr{},
|
||||
}
|
||||
if err = e.EncodeElement(value, elem); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err = e.EncodeToken(xml.EndElement{start.Name}); err != nil {
|
||||
return err
|
||||
}
|
||||
e.EncodeToken(xml.EndElement{start.Name})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user