Convenience Functions
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 XMLReader
object. 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 the source
parameter, which may be a filename, URL, a file object open for
reading, or an InputSource
instance.
parseString(
text, content_handler[, error_handler]
)
Similar to parse
, but the input document is the
text given by text
.