Compare commits

...

2 Commits

Author SHA1 Message Date
pzx521521
a2f2fbf6c3
Merge 2ae5988db30756a7cf256d35019dc5151806387f into f5c267d2f84ba8192dd9c4c67b0490abfa3dfe7a 2026-02-15 03:54:54 -04:00
pzx521521
2ae5988db3
Update xml.go
here is xml.Unmarshal problem if xml have muti-root:

[unmarshal-xml-array-in-golang-only-getting-the-first-element](https://stackoverflow.com/questions/27553274/unmarshal-xml-array-in-golang-only-getting-the-first-element)

[so  gin have same problem](https://stackoverflow.com/questions/74226570/golang-gin-binding-request-body-xml-to-slice):

if gin bind muti-root-xml, it should use for util io.EOF
2022-10-28 14:28:08 +08:00

View File

@ -27,8 +27,13 @@ func (xmlBinding) BindBody(body []byte, obj any) error {
func decodeXML(r io.Reader, obj any) error {
decoder := xml.NewDecoder(r)
if err := decoder.Decode(obj); err != nil {
return err
for {
if err := decoder.Decode(obj); err != nil {
if err == io.EOF{
break
}
return err
}
}
return validate(obj)
}