Adds optional indented output for the Node.String() and Node.Bytes()
methods. Set the global `IndentPrefix` var to a tab or spaces to enable indented output. The existing API has not been changed. This addresses issue #7.
This commit is contained in:
parent
88d4341915
commit
c085b35fb9
4 changed files with 92 additions and 17 deletions
|
@ -29,7 +29,6 @@ package xmlx
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
//"code.google.com/p/go-charset/charset"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -206,6 +205,10 @@ func (this *Document) SaveBytes() []byte {
|
|||
if this.SaveDocType {
|
||||
b.WriteString(fmt.Sprintf(`<?xml version="%s" encoding="%s" standalone="%s"?>`,
|
||||
this.Version, this.Encoding, this.StandAlone))
|
||||
|
||||
if len(IndentPrefix) > 0 {
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
|
||||
b.Write(this.Root.Bytes())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue