如何让自定义类型在xml.Marshal下生成CDATA格式

如题所述

参考:

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
    return e.EncodeElement(struct {
        string `xml:",cdata"`
    }{string(c)}, start)
}

温馨提示:答案为网友推荐,仅供参考
相似回答