Python xml.sax: support for SAX2 parsers
Answer: A typical SAX application uses three kinds of objects: readers, handlers and input sources.
Convenience functions
The package itself provides the SAX exceptions and the convenience functions most used by users of the SAX API.
make_parser creates and returns a SAX XMLReader object.
The first parser found will be used.
The handler parameter needs to be a SAX ContentHandler instance.
There is no return value; all work must be done by the handler passed in.
Security and typical shape
If you need to parse untrusted or unauthenticated data, see the XML security guidance.
The SAX parser no longer processes general external entities by default, which increases security.
A typical SAX application uses three kinds of objects: readers, handlers and input sources.
The reader invokes a method on the handler.
See also
Claims
- id: C1 claim: A typical SAX application uses three kinds of objects: readers, handlers and input sources. source: S1 evidence: "A typical SAX application uses three kinds of objects: readers, handlers and input sources."
- id: C2 claim: The first parser found will be used. source: S1 evidence: "The first parser found will be used."
- id: C3 claim: There is no return value; all work must be done by the handler passed in. source: S1 evidence: "There is no return value; all work must be done by the handler passed in."
- id: C4 claim: The SAX parser no longer processes general external entities by default. source: S2 evidence: "The SAX parser no longer processes general external entities by default"
Sources
- [S1] xml.sax — Support for SAX2 parsers. Python Software Foundation. https://docs.python.org/3/library/xml.sax.html . License: PSF License Version 2. Accessed 2026-11-24.
- [S2] xml.sax documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/xml.sax.rst . License: PSF License Version 2. Accessed 2026-11-24.
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.sax — Support for SAX2 parsers; CPython, xml.sax 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.sax — Support for SAX2 parsers; CPython, xml.sax documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python xml.sax: support for SAX2 parsers." iinventedlight Library, iil:note:a62q8d7w, version of 2026-11-24. https://iinventedlight.com/library/notes/python-xml-sax/. License: CC-BY-4.0.
@misc{iil_note_a62q8d7w,
author = {{iinventedlight}},
title = {{Python xml.sax: support for SAX2 parsers}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/python-xml-sax/},
note = {Permanent ID iil:note:a62q8d7w. 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.
- python-xml-sax.schema.json (schema; CC-BY-4.0)
- python-xml-sax.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/python-xml-sax.md.