October 2015
Beginner to intermediate
400 pages
14h 44m
English
Section 4.5 showed how to decode JSON documents into
Go data structures with the Marshal and Unmarshal
functions from the encoding/json package.
The encoding/xml package provides a similar API.
This approach is convenient when we want to construct a representation of
the document tree, but that’s unnecessary for many programs.
The encoding/xml package also provides a lower-level
token-based API for decoding XML.
In the token-based style, the parser consumes the input and produces a
stream of tokens, primarily of four kinds—StartElement,
EndElement, CharData, and Comment—each being
a concrete type in the encoding/xml package.
Each call to (*xml.Decoder).Token returns a token.
The relevant parts of ...