Standard library / encoding/xml
encoding/xml.Token
Union-like any type; use a type switch to handle each concrete XML token kind. Expected stdout: 'start\n'.
Formal Syntax & Structure
go syntaxgo
type Token anyWorking Example
Example Snippetgo
package main
import ( "encoding/xml" "fmt" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { d := xml.NewDecoder(strings.NewReader("<a/>")) t, e := d.Token() must(e) switch t.(type) { case xml.StartElement: fmt.Println("start") }}