← All notes

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

Sources

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

Permanent ID: iil:note:0h999dp5

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.},
}

Markdown

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.

All artifact files (JSON index)

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.