-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
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. :-)
melato
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.