I have a type,
type Example struct {
XMLName xml.Name `xml:"example example"`
Attr1 string `xml:"attr1,attr"`
}
If I try to encode this using xml.Encoder to stdout writer,
enc := xml.NewEncoder(os.Stdout)
v := &Example{Attr1: "attr1"}
if err := enc.Encode(v); err != nil {
fmt.Printf("error: %v
", err)
}
it encodes this element with the closing tag, i.e.
<example xmlns="example" attr1="attr1"></example>
But I want to encode only the opening tag, i.e.
<example xmlns="example" attr1="attr1">
Is this possible?