Standard library / encoding/xml
encoding/xml.NewDecoder()
Creates a streaming XML decoder, strict by default. Configure options before reading. Expected stdout: 'a\n'.
Formal Syntax & Structure
go syntaxgo
func NewDecoder(r io.Reader) *DecoderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | io.Reader | Input stream. |
Return Value
*Decoder
New XML decoder.
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("<a/>")) t, e := d.Token() must(e) fmt.Println(t.(xml.StartElement).Name.Local)}