mirror of
https://github.com/golang/go
synced 2024-11-21 16:44:43 -07:00
encoding/xml: fix decoding of xml.Name with sub-elements
R=golang-dev, adg CC=golang-dev https://golang.org/cl/5569090
This commit is contained in:
parent
ff8133d42e
commit
9c497443ae
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user