WriteTo serializes the document out to the writer 'w'. The function returns the number of bytes written and any error encountered.
(w io.Writer)
| 443 | // WriteTo serializes the document out to the writer 'w'. The function returns |
| 444 | // the number of bytes written and any error encountered. |
| 445 | func (d *Document) WriteTo(w io.Writer) (n int64, err error) { |
| 446 | xw := newXmlWriter(w) |
| 447 | b := bufio.NewWriter(xw) |
| 448 | for _, c := range d.Child { |
| 449 | c.WriteTo(b, &d.WriteSettings) |
| 450 | } |
| 451 | err, n = b.Flush(), xw.bytes |
| 452 | return |
| 453 | } |
| 454 | |
| 455 | // WriteToFile serializes the document out to the file at path 'filepath'. |
| 456 | func (d *Document) WriteToFile(filepath string) error { |