Standard library / encoding/xml
encoding/xml.StartElement
Represents an opening tag with its Name and attributes. An empty element yields a start and end token. Expected stdout: 'a 7\n'.
Formal Syntax & Structure
go syntaxgo
type StartElement struct { Name Name Attr []Attr}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 id="7"/>`)) t, e := d.Token() must(e) s := t.(xml.StartElement) fmt.Println(s.Name.Local, s.Attr[0].Value)}