Markup Processing Modules
xml.sax.saxutils
Utility functions and handlers for SAX XML output and input preparation. escape() handles XML text characters; quoteattr() produces a quoted attribute value. XMLGenerator writes XML from events. Escaping text is not a general sanitizer or validation of a document. Use bounded trusted XML; parsing hostile input requires a security review and resource limits.
Formal Syntax & Structure
python syntaxpython
import xml.sax.saxutilsReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from xml.sax.saxutils import escape, quoteattrprint(escape("A < B & C"))print(quoteattr("red & blue"))