Standard library / encoding/xml

encoding/xml.Name

Holds namespace URI in Space and local name in Local when returned by Token. Prefix text is not the namespace URI. Expected stdout: 'urn:x a\n'.

Formal Syntax & Structure

go syntaxgo
type Name struct {  Space, Local string}

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.Token()  must(e)  n := t.(xml.StartElement).Name  fmt.Println(n.Space, n.Local)}
Go Reference