DecodeElement works like Unmarshal except that it takes a pointer to the start XML element to decode into v. It is useful when a client reads some raw XML tokens itself but also wants to defer to Unmarshal for some elements.
(v any, start *StartElement)
| 145 | // It is useful when a client reads some raw XML tokens itself |
| 146 | // but also wants to defer to Unmarshal for some elements. |
| 147 | func (d *Decoder) DecodeElement(v any, start *StartElement) error { |
| 148 | val := reflect.ValueOf(v) |
| 149 | if val.Kind() != reflect.Pointer { |
| 150 | return errors.New("non-pointer passed to Unmarshal") |
| 151 | } |
| 152 | |
| 153 | if val.IsNil() { |
| 154 | return errors.New("nil pointer passed to Unmarshal") |
| 155 | } |
| 156 | return d.unmarshal(val.Elem(), start, 0) |
| 157 | } |
| 158 | |
| 159 | // An UnmarshalError represents an error in the unmarshaling process. |
| 160 | type UnmarshalError string |