Name
Convenience Functions
Synopsis
Three important convenience functions make performing a
SAX-based parse trivial. These are sufficient for most applications,
especially if the only handler that’s needed is the ContentHandler. These functions are provided
in the xml.sax module and work with
both the standard library and PyXML.
make_parser([parser_list])Returns a SAX
XMLReaderobject. Most of the examples in Chapter 3 use this function to create a reader. See also Section 3.7, in that chapter, for more information on using the underlying parser factory objects.parse(source, content_handler[, error_handler])Creates a reader using
make_parser, associates the provided content and error handlers, and parses an XML document. The document is identified by thesourceparameter, which may be a filename, URL, a file object open for reading, or anInputSourceinstance.parseString(text, content_handler[, error_handler])Similar to
parse, but the input document is the text given bytext.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access