Section 4.5 showed how to decode JSON documents into
Go data structures with the
functions from 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.
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—
a concrete type in the
Each call to
(*xml.Decoder).Token returns a token.
The relevant parts of ...