Name

XMLReader

Synopsis

This is the basic parser interface used in SAX 2. It provides methods to get and set the handler objects and a control variety of configurable options.

parse( source )

Starts the parser working on the document in the entity identified by source. The parameter may be a filename, a URL, or an InputSource object. The InputSource interface is described later in this Appendix.

getContentHandler( )

Returns the currently configured content handler, or None if there isn’t one.

getDTDHandler( )

Returns the currently configured DTD handler, or None if there isn’t one.

getEntityResolver( )

Returns the currently configured entity resolver, or None if there isn’t one.

getErrorHandler( )

Returns the currently configured error handler, or None if there isn’t one.

getFeature( name )

Get the current Boolean value for the feature identified by name. This method returns true if the feature is enabled, and false if it is disabled, or it raises the SAXNotRecognized or SAXNotSupported exception if name is not known or supported.

getProperty( name )

Returns the current value of the property identified by name. This method returns whatever Python object is appropriate for the specific property; the application must be written to follow the rules associated with that property. If the specific property for which the value is requested is not known or supported by the parser, the appropriate subclass of the SAXException is raised as an exception.

setContentHandler( handler )

Sets the content handler to handler, which must conform to the ContentHandler interface (described next). If handler is None, content events are not reported.

setDTDHandler( handler )

Sets the DTD handler to handler, which must conform to the DTDHandler interface described later in this reference. If handler is None, information about unparsed entities is not provided to the application.

setEntityResolver( resolver )

Sets the entity resolver to handler, which must conform to the EntityResolver interface. This interface is described in more detail later in this reference. If handler is None, the default behavior is to allow the parser to determine whether and how external entities are accessed. Many parsers have at least some ability to load external entities.

setErrorHandler( handler )

Sets the error handler to handler, which must conform to the ErrorHandler interface. This interface is described in more detail later in this reference. If handler is None, the default behavior is used.

setFeature( name, value )

Enables or disables the parser feature identified by name. The feature is enabled if value is true, or disabled if it is false. If the feature is not known, the exception SAXNotRecognized is thrown; if the particular value is not supported, SAXNotSupported is raised. Some features must be set before the parse begins, and others may be set at any time.

setLocale( locale )

Sets the locale for the error messages from the parser. If the parser does not support the indicated locale, a SAX exception is raised. The application may choose to catch and ignore the exception, but the locale does not change. The application may change the locale at any time.

setProperty( name, value )

Sets the value of the property identified by name to value. The parser checks that value is of the right type for the specific property and may raise an exception if it is not. If the property name is not known or supported by the parser, the appropriate exception is raised. Some properties must be set before the parse begins, and others may be set at any time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.245.233