Standard library / encoding/xml

encoding/xml.CopyToken()

Copies an XML token; use before storing byte-backed tokens beyond the next decoder read. Expected stdout: 'Go\n'.

Formal Syntax & Structure

go syntaxgo
func CopyToken(t Token) Token

Parameters & Attributes

NameTypeDescription
tTokenXML token or token reader, according to the signature.

Return Value

Token

Copied token.

Working Example

Example Snippetgo
package main
import (  "encoding/xml"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  v := xml.CharData("Go")  c := xml.CopyToken(v).(xml.CharData)  v[0] = 88  fmt.Println(string(c))}
Go Reference