evcc-io/util/request/xml.go
2025-10-12 14:42:51 +02:00

21 lines
311 B
Go

package request
import (
"bytes"
"encoding/xml"
"io"
)
// MarshalXML marshals XML into an io.ReadSeeker
func MarshalXML(data interface{}) io.ReadSeeker {
if data == nil {
return nil
}
body, err := xml.Marshal(data)
if err != nil {
return &errorReader{err: err}
}
return bytes.NewReader(body)
}