Skip to content

Commit 66591fb

Browse files
committed
fixed #14
1 parent 99ab1df commit 66591fb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎node.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func outputXML(b *strings.Builder, n *Node, level int, skip bool) {
7575
b.WriteString(fmt.Sprintf("%v", n.value))
7676
return
7777
}
78-
7978
if v := reflect.ValueOf(n.value); v.Kind() == reflect.Slice {
8079
for child := n.FirstChild; child != nil; child = child.NextSibling {
8180
b.WriteString("<" + n.Data + ">")
@@ -86,13 +85,18 @@ func outputXML(b *strings.Builder, n *Node, level int, skip bool) {
8685
d := n.Data
8786
if !skip {
8887
if d == "" {
89-
d = fmt.Sprintf("%v", n.value)
88+
if v := reflect.ValueOf(n.value); v.Kind() == reflect.Map {
89+
d = "element"
90+
} else {
91+
d = fmt.Sprintf("%v", n.value)
92+
}
9093
}
9194
b.WriteString("<" + d + ">")
9295
}
93-
94-
for child := n.FirstChild; child != nil; child = child.NextSibling {
95-
outputXML(b, child, level, false)
96+
if reflect.TypeOf(n.value) != nil {
97+
for child := n.FirstChild; child != nil; child = child.NextSibling {
98+
outputXML(b, child, level, false)
99+
}
96100
}
97101
if !skip {
98102
b.WriteString("</" + d + ">")

0 commit comments

Comments
 (0)