LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package xml | 5 package xml |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "errors" | 9 "errors" |
10 "fmt" | 10 "fmt" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // beginning with the given start element. | 145 // beginning with the given start element. |
146 // If it returns an error, the outer call to Unmarshal stops and | 146 // If it returns an error, the outer call to Unmarshal stops and |
147 // returns that error. | 147 // returns that error. |
148 // UnmarshalXML must consume exactly one XML element. | 148 // UnmarshalXML must consume exactly one XML element. |
149 // One common implementation strategy is to unmarshal into | 149 // One common implementation strategy is to unmarshal into |
150 // a separate value with a layout matching the expected XML | 150 // a separate value with a layout matching the expected XML |
151 // using d.DecodeElement, and then to copy the data from | 151 // using d.DecodeElement, and then to copy the data from |
152 // that value into the receiver. | 152 // that value into the receiver. |
153 // Another common strategy is to use d.Token to process the | 153 // Another common strategy is to use d.Token to process the |
154 // XML object one token at a time. | 154 // XML object one token at a time. |
| 155 // UnmarshalXML may not use d.RawToken. |
155 type Unmarshaler interface { | 156 type Unmarshaler interface { |
156 UnmarshalXML(d *Decoder, start StartElement) error | 157 UnmarshalXML(d *Decoder, start StartElement) error |
157 } | 158 } |
158 | 159 |
159 // Unmarshaler is the interface implemented by objects that can unmarshal | 160 // UnmarshalerAttr is the interface implemented by objects that can unmarshal |
160 // an XML attribute description of themselves. | 161 // an XML attribute description of themselves. |
161 // | 162 // |
162 // UnmarshalXMLAttr decodes a single XML attribute. | 163 // UnmarshalXMLAttr decodes a single XML attribute. |
163 // If it returns an error, the outer call to Unmarshal stops and | 164 // If it returns an error, the outer call to Unmarshal stops and |
164 // returns that error. | 165 // returns that error. |
165 // UnmarshalXMLAttr is used only for struct fields with the | 166 // UnmarshalXMLAttr is used only for struct fields with the |
166 // "attr" option in the field tag. | 167 // "attr" option in the field tag. |
167 type UnmarshalerAttr interface { | 168 type UnmarshalerAttr interface { |
168 UnmarshalXMLAttr(attr Attr) error | 169 UnmarshalXMLAttr(attr Attr) error |
169 } | 170 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 switch tok.(type) { | 622 switch tok.(type) { |
622 case StartElement: | 623 case StartElement: |
623 if err := d.Skip(); err != nil { | 624 if err := d.Skip(); err != nil { |
624 return err | 625 return err |
625 } | 626 } |
626 case EndElement: | 627 case EndElement: |
627 return nil | 628 return nil |
628 } | 629 } |
629 } | 630 } |
630 } | 631 } |
LEFT | RIGHT |