WriteTo writes the XML representation of the start element to the provided writer.
(w TokenWriter)
| 20 | |
| 21 | // WriteTo writes the XML representation of the start element to the provided writer. |
| 22 | func (e *StartElement) WriteTo(w TokenWriter) error { |
| 23 | if err := w.WriteByte('<'); err != nil { |
| 24 | return err |
| 25 | } |
| 26 | if _, err := w.WriteString(e.Name.String()); err != nil { |
| 27 | return err |
| 28 | } |
| 29 | |
| 30 | e.writeAttrsTo(w) |
| 31 | |
| 32 | if e.SelfClosing { |
| 33 | if _, err := w.WriteString("/>"); err != nil { |
| 34 | return err |
| 35 | } |
| 36 | return nil |
| 37 | } |
| 38 | |
| 39 | if err := w.WriteByte('>'); err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | // writeAttrsTo writes the attributes of the start element to the provided writer. |
| 47 | func (e *StartElement) writeAttrsTo(w TokenWriter) error { |
no test coverage detected