Skip to content

Commit

Permalink
Merge pull request subchen#3 from konsorten/master
Browse files Browse the repository at this point in the history
Added extended pretty printing
  • Loading branch information
subchen authored Mar 1, 2018
2 parents 63d6b99 + c775891 commit e1029cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions document.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,17 @@ func (d *Document) XMLPretty() string {
buf.WriteString(d.Root.XMLPretty())
return buf.String()
}

func (d *Document) XMLPrettyEx(indent string) string {
buf := new(bytes.Buffer)
if len(d.ProcInst) > 0 {
buf.WriteString(d.ProcInst)
buf.WriteByte('\n')
}
for _, directive := range d.Directives {
buf.WriteString(directive)
buf.WriteByte('\n')
}
buf.WriteString(d.Root.XMLPrettyEx(indent))
return buf.String()
}
6 changes: 6 additions & 0 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,9 @@ func (n *Node) XMLPretty() string {
printXML(buf, n, 0, " ")
return buf.String()
}

func (n *Node) XMLPrettyEx(indent string) string {
buf := new(bytes.Buffer)
printXML(buf, n, 0, indent)
return buf.String()
}

0 comments on commit e1029cd

Please sign in to comment.