case "":
case "chardata":
if tk := f.Type.Kind(); tk == reflect.String {
- p.Write([]byte(val.Field(i).String()))
+ Escape(p, []byte(val.Field(i).String()))
} else if tk == reflect.Slice {
if elem, ok := val.Field(i).Interface().([]byte); ok {
Escape(p, elem)
Name []byte `xml:"chardata"`
}
+type Book struct {
+ XMLName Name `xml:"book"`
+ Title string `xml:"chardata"`
+}
+
type SecretAgent struct {
XMLName Name `xml:"agent"`
Handle string `xml:"attr"`
{Value: &Port{Number: "443"}, ExpectXML: `<port>443</port>`},
{Value: &Port{Type: "<unix>"}, ExpectXML: `<port type="<unix>"></port>`},
{Value: &Domain{Name: []byte("google.com&friends")}, ExpectXML: `<domain>google.com&friends</domain>`},
+ {Value: &Book{Title: "Pride & Prejudice"}, ExpectXML: `<book>Pride & Prejudice</book>`},
{Value: atomValue, ExpectXML: atomXml},
{
Value: &Ship{