AnyMap -> XmlStringMap

This commit is contained in:
白茶清欢 2024-11-04 17:23:08 +08:00
parent 8b8d3c3384
commit ecb0211345

10
xml.go
View File

@ -68,14 +68,14 @@ func (o *ownXml) MarshalForStringIgnoreError(input any) string {
return str return str
} }
type AnyMap map[string]any type XmlStringMap map[string]string
type xmlMapEntry struct { type xmlMapEntry struct {
XMLName xml.Name XMLName xml.Name
Value any `xml:",chardata"` Value string `xml:",chardata"`
} }
func (m *AnyMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { func (m *XmlStringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if nil == m { if nil == m {
return nil return nil
} }
@ -95,8 +95,8 @@ func (m *AnyMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeToken(start.End()) return e.EncodeToken(start.End())
} }
func (m *AnyMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { func (m *XmlStringMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
*m = AnyMap{} *m = XmlStringMap{}
for { for {
var e xmlMapEntry var e xmlMapEntry