← All notes

Python xml.parsers.expat: fast XML parsing using Expat

Answer: xml.parsers.expat is a Python interface to Expat, a non-validating XML parser.

What the module provides

It exposes a single xmlparser extension type that holds parser state.

Various attributes of the object can be set to handler functions.

Those handlers then run for character data and markup as a document is fed in.

Access to Expat goes through pyexpat, and calling pyexpat directly is deprecated.

Errors, versions, and encodings

ExpatError is the exception raised when Expat reports an error.

ParserCreate returns a new xmlparser, and XMLParserType is that return type.

version_info is a tuple of three integers: major, minor and micro version.

Expat's repertoire of encodings can't be extended.

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: Python Software Foundation, xml.parsers.expat — Fast XML parsing using Expat; CPython, xml.parsers.expat documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, xml.parsers.expat — Fast XML parsing using Expat; CPython, xml.parsers.expat documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:4dgve0mx

iinventedlight. 2026. "Python xml.parsers.expat: fast XML parsing using Expat." iinventedlight Library, iil:note:4dgve0mx, version of 2026-11-24. https://iinventedlight.com/library/notes/python-expat/. License: CC-BY-4.0.

@misc{iil_note_4dgve0mx,
  author = {{iinventedlight}},
  title = {{Python xml.parsers.expat: fast XML parsing using Expat}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-expat/},
  note = {Permanent ID iil:note:4dgve0mx. 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/python-expat.md.