12.4. Event-driven Processing

In chapter 10, we saw how the popular event-driven XML processing style can be used in Python with the Python implementation of the SAX API. Pyxie also provides event-driven XML-processing capabilities. Perhaps the biggest difference is that with Pyxie, event handlers can be named after the element types that they process. This is best illustrated by example. The following program has code to handle start-tags for greeting elements and end-tags for b elements. It also has a handler for data content that prints out the first four characters of the data.

CD-ROM reference=12006.txt
C>type p6.py """ Event-driven XML processing with Pyxie """ from pyxie import * # Create a class derived from xDispatch. class myHandler(xDispatch): ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.