Encoding/xml
encoding/xml is Go’s standard-library package for encoding Go values as XML and decoding XML data into Go values.
Learn Go with Pocket-Sized Projects
encoding/xml is Go's standard-library package for encoding and decoding XML data.
- How it is used
- Decodes XML HTTP responses into Go structures for an exchange-rate client.
- How deep it goes
- Explains Decoder selection, struct tags, nested paths, attributes, and error handling without descending into decoder internals.
- Examples
- Uses an ECB envelope containing nested Cube elements and currency and rate attributes.
- What you can do after
- Apply it via Go's standard library to decode XML streams into tagged structures and process the resulting data.
Read how Learn Go with Pocket-Sized Projects explains encoding/xml →
Go in Action, Second Edition
encoding/xml is a Go standard-library package for encoding and decoding XML documents.
- How it is used
- Converts structured configuration and document data between XML and Go values, including JSON-to-XML CLI workflows.
- How deep it goes
- Explains struct tags, attributes, namespaces, comments, and conversion flow, while stopping short of exhaustive XML API coverage.
- Examples
- Uses a Config struct and a JSON-to-XML conversion function within a validation and conversion CLI.
- What you can do after
- Build XML serialization and parsing with Go structs, XML tags, and the encoding/xml Marshal and Unmarshal functions.
Read how Go in Action, Second Edition explains encoding/xml →
Related concepts
- xmluses · XML is a text-based markup language for encoding structured documents and data using elements, attributes, and nested relationships.
- struct taguses · A struct tag is metadata attached to a Go struct field that guides reflection-based processing such as serialization and field mapping.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

