June 2000
Intermediate to advanced
556 pages
8h 45m
English
We now have covered all the material on SAX required to build a SAX application that generates PYX. This facility will be part of the Pyxie library later on, but a standalone version of the routine is shown here to illustrate a SAX application.
CD-ROM reference=10034.txt #! /usr/bin/env python """ Utility to create PYX notation from the default SAX-compliant parser Sean Mc Grath XML Processing with Python """ # Import the SAX modules. from xml.sax import saxexts, saxlib, saxutils import string def Encode (s): """ Convert line ends to the two character sequence '\' followed by 'n'. """ return string.replace (s,"\n","\\n") class myHandler (saxlib.DocumentHandler): def startElement(self,Element,Attributes): print "(%s" ...
Read now
Unlock full access