You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. capture the code in this description to xml_parse.go
2. go run xml_parse.go
What is the expected output?
a::b::c::nil
What do you see instead?
:: nil
Which compiler are you using (5g, 6g, 8g, gccgo)?
go
Which operating system are you using?
archlinux x86_64
Which revision are you using? (hg identify)
58bc8aae4abb
Please provide any additional information below.
// sample from http://research.swtch.com/godata2
package main
import (
"encoding/xml"
"fmt"
"log"
)
var encoded = `
<list><value>a</value>
<list><value>b</value>
<list><value>c</value>
</list>
</list>
</list>
`
type List struct {
Value string
List *List
}
func (l *List) String() string {
if l == nil {
return "nil"
}
return l.Value + " :: " + l.List.String()
}
func main() {
var l *List
err := xml.Unmarshal([]byte(encoded),&l)
if err != nil {
log.Fatalln("xml.Unmarshal: ", err)
}
fmt.Println(l)
}
The text was updated successfully, but these errors were encountered:
Here is my modified code, it works.
I think this issue could closed.
// sample from http://research.swtch.com/godata2
package main
import (
"encoding/xml"
"fmt"
"log"
)
var encoded = `
<List><value>a</value>
<List><value>b</value>
<List><value>c</value>
</List>
</List>
</List>
`
type List struct {
Value string `xml:"value"`
List *List
}
func (l *List) String() string {
if l == nil {
return "nil"
}
return l.Value + " :: " + l.List.String()
}
func main() {
var l *List
err := xml.Unmarshal([]byte(encoded),&l)
if err != nil {
log.Fatalln("xml.Unmarshal: ", err)
}
fmt.Println(l)
}
The text was updated successfully, but these errors were encountered: