Standard library / encoding/xml

encoding/xml.Decoder.RawToken()

Reads without matching start/end elements or resolving namespace prefixes. Use Token for structural checks. Expected stdout: 'p\n'.

Formal Syntax & Structure

go syntaxgo
func (d *Decoder) RawToken() (Token, error)

Return Value

(Token, error)

Token and error, including io.EOF at end of input.

Working 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(`<p:a xmlns:p="urn:x"/>`))  t, e := d.RawToken()  must(e)  fmt.Println(t.(xml.StartElement).Name.Space)}
Go Reference