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