Go encoding/xml: a simple XML 1.0 parser
Answer: Package xml implements a simple XML 1.0 parser that understands XML name spaces. Marshal returns the XML encoding of v. Unmarshal parses XML-encoded data and stores the result in v.
Marshaling and tokens
The package implements a simple XML 1.0 parser that understands XML name spaces.
Marshal returns the XML encoding of v. MarshalIndent is like Marshal but applies Indent to format the output.
Unmarshal parses XML-encoded data and stores the result in v.
A Decoder reads and decodes XML tokens. An Encoder writes XML tokens.
The source comment
The source comment describes a simple XML 1.0 parser that understands XML name spaces.
References include the annotated XML spec and XML name spaces.
A SyntaxError represents a syntax error in the XML input stream.
When Token encounters an unrecognized name space prefix, it uses that prefix as the Space rather than report an error.
See also
Claims
- id: C1 claim: The package implements a simple XML 1.0 parser that understands name spaces. source: S1 evidence: "a simple XML 1.0 parser that understands XML name spaces"
- id: C2 claim: Marshal encodes a value to XML bytes. source: S1 evidence: "func Marshal(v any) ([]byte, error)"
- id: C3 claim: The source comment describes a simple XML 1.0 parser. source: S2 evidence: "Package xml implements a simple XML 1.0 parser that"
- id: C4 claim: The parser understands XML name spaces. source: S2 evidence: "understands XML name spaces."
Sources
- [S1] encoding/xml package reference. Go. https://pkg.go.dev/encoding/xml . License: BSD-3-Clause. Accessed 2026-11-23.
- [S2] encoding/xml source. Go. https://go.dev/src/encoding/xml/xml.go . License: BSD-3-Clause. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, encoding/xml package reference; Go, encoding/xml source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go, encoding/xml package reference; Go, encoding/xml source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go encoding/xml: a simple XML 1.0 parser." iinventedlight Library, iil:note:0h999dp5, version of 2026-11-23. https://iinventedlight.com/library/notes/go-encoding-xml/. License: CC-BY-4.0.
@misc{iil_note_0h999dp5,
author = {{iinventedlight}},
title = {{Go encoding/xml: a simple XML 1.0 parser}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/go-encoding-xml/},
note = {Permanent ID iil:note:0h999dp5. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-encoding-xml.schema.json (schema; CC-BY-4.0)
- go-encoding-xml.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-encoding-xml.md.