Commit 9c497443 authored by Gustavo Niemeyer's avatar Gustavo Niemeyer

encoding/xml: fix decoding of xml.Name with sub-elements

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5569090
parent ff8133d4
......@@ -532,6 +532,11 @@ var marshalTests = []struct {
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`,
},
{
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
ExpectXML: `<NameInField><foo xmlns="ns"><ignore></ignore></foo></NameInField>`,
UnmarshalOnly: true,
},
// Marshaling zero xml.Name uses the tag or field name.
{
......
......@@ -265,12 +265,13 @@ func (p *Decoder) unmarshal(val reflect.Value, start *StartElement) error {
saveData = v
case reflect.Struct:
sv = v
typ := sv.Type()
typ := v.Type()
if typ == nameType {
v.Set(reflect.ValueOf(start.Name))
break
}
sv = v
tinfo, err = getTypeInfo(typ)
if err != nil {
return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment