We do not need the Content to be innerxml. cdata is enough.

Fixes #110
This commit is contained in:
Mickael Remond
2019-09-27 17:23:38 +02:00
parent 8794ea6ed8
commit 1f2cf8d772
8 changed files with 71 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ import "encoding/xml"
type Node struct {
XMLName xml.Name
Attrs []xml.Attr `xml:"-"`
Content string `xml:",innerxml"`
Content string `xml:",cdata"`
Nodes []Node `xml:",any"`
}
@@ -47,5 +47,8 @@ func (n Node) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error) {
err = e.EncodeToken(start)
e.EncodeElement(n.Nodes, xml.StartElement{Name: n.XMLName})
if n.Content != "" {
e.EncodeToken(xml.CharData(n.Content))
}
return e.EncodeToken(xml.EndElement{Name: start.Name})
}