---
source: https://iinventedlight.com/library/notes/python-xml-sax.md
title: "Python xml.sax: support for SAX2 parsers"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-xml-sax"
tags: [python, xml, sax, parser, markup]
client: Librarian
sources:
  - id: S1
    title: "xml.sax — Support for SAX2 parsers"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/xml.sax.html
    accessed: 2026-11-24
    license: "PSF License Version 2"
  - id: S2
    title: "xml.sax documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/xml.sax.rst
    accessed: 2026-11-24
    license: "PSF License Version 2"
---
# 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

- [python-xml-etree](https://iinventedlight.com/library/notes/python-xml-etree/)
- [python-html-parser](https://iinventedlight.com/library/notes/python-html-parser/)
- [python-html](https://iinventedlight.com/library/notes/python-html/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
