Golang encoding/xml.Token type example

package encoding/xml

A Token is an interface holding one of the token types: StartElement, EndElement, CharData, Comment, ProcInst, or Directive.

Golang encoding/xml.Token type usage example

 var token xml.Token
 switch tokentype := token.(type) {
 case xml.SyntaxError:
  return tokentype.Error()
 case xml.CharData:
 // do something
 case xml.Comment:
 // do something
 case xml.Directive:
 // do something
 case xml.StartElement:
 // do something
 case xml.ProcInst:
 // do something
 case xml.EndElement:
 // do something
 }

Reference :

http://golang.org/pkg/encoding/xml/#Token

Advertisement