Open
Description
Marshaling xml with prefix and indent set to empty strings results in unindented xml. Tested in Go 1.5.1 darwin/amd64.
The following code:
package main
import (
"encoding/xml"
"fmt"
)
type Person struct {
XMLName xml.Name `xml:"person"`
Id int `xml:"id,attr"`
FirstName string `xml:"name>first"`
LastName string `xml:"name>last"`
Age int `xml:"age"`
}
func main() {
v := &Person{Id: 13, FirstName: "John", LastName: "Doe", Age: 42}
output, err := xml.MarshalIndent(v, "", "")
if err != nil {
fmt.Printf("error: %v\n", err)
}
fmt.Println(string(output))
}
gives:
<person id="13"><name><first>John</first><last>Doe</last></name><age>42</age></person>
but expteded was:
<person id="13">
<name>
<first>John</first>
<last>Doe</last>
</name>
<age>42</age>
</person>
I know, not major, but believe it or not, I actually need the latter behavior. :-)