Standard library / encoding/xml
encoding/xml.Encoder
Writes XML to an io.Writer. Close checks token balance and flushes pending output. Expected stdout: '<string>Go</string>\n'.
Formal Syntax & Structure
go syntaxgo
type Encoder struct { // Has unexported fields.}Working Example
Example Snippetgo
package main
import ( "bytes" "encoding/xml" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { var out bytes.Buffer enc := xml.NewEncoder(&out) must(enc.Encode("Go")) must(enc.Close()) fmt.Println(out.String())}