Standard library / encoding/xml

encoding/xml.TokenReader

Interface providing successive XML tokens. NewTokenDecoder adapts it to a Decoder. Expected stdout: 'a\n'.

Formal Syntax & Structure

go syntaxgo
type TokenReader interface {  Token() (Token, error)}

Working Example

Example Snippetgo
package main
import (  "encoding/xml"  "fmt"  "strings")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var tr xml.TokenReader = xml.NewDecoder(strings.NewReader("<a/>"))  t, e := tr.Token()  must(e)  fmt.Println(t.(xml.StartElement).Name.Local)}
Go Reference