Markup Processing Modules
xml.sax.handler
Base classes and feature/property constants for SAX event handlers. ContentHandler receives document, element and character events; other interfaces handle errors, entities and DTD-related events. Applications override needed callbacks and register handlers with a parser. Use bounded trusted XML; parsing hostile input requires a security review and resource limits.
Formal Syntax & Structure
python syntaxpython
import xml.sax.handlerReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from xml.sax import parseStringfrom xml.sax.handler import ContentHandlerclass Items(ContentHandler): def startElement(self, name, attrs): if name == "item": print(attrs["id"])parseString('<r><item id="5"/></r>', Items())