|  | Home · All Classes · Modules

# QXmlReader Class Reference
[QtXml module]

The QXmlReader class provides an interface for XML readers (i.e. parsers). More...

Inherited by QXmlSimpleReader.

### Methods

- __init__ (self)
- __init__ (self, QXmlReader)
- QXmlContentHandler contentHandler (self)
- QXmlDeclHandler declHandler (self)
- QXmlDTDHandler DTDHandler (self)
- QXmlEntityResolver entityResolver (self)
- QXmlErrorHandler errorHandler (self)
- (bool, bool ok) feature (self, QString)
- bool hasFeature (self, QString)
- bool hasProperty (self, QString)
- QXmlLexicalHandler lexicalHandler (self)
- bool parse (self, QXmlInputSource)
- bool parse (self, QXmlInputSource)
- (sip.voidptr, bool ok) property (self, QString)
- setContentHandler (self, QXmlContentHandler)
- setDeclHandler (self, QXmlDeclHandler)
- setDTDHandler (self, QXmlDTDHandler)
- setEntityResolver (self, QXmlEntityResolver)
- setErrorHandler (self, QXmlErrorHandler)
- setFeature (self, QString, bool)
- setLexicalHandler (self, QXmlLexicalHandler)
- setProperty (self, QString, sip.voidptr)

## Detailed Description

The QXmlReader class provides an interface for XML readers (i.e. parsers).

This abstract class provides an interface for all of Qt's XML readers. Currently there is only one implementation of a reader included in Qt's XML module: QXmlSimpleReader. In future releases there might be more readers with different properties available (e.g. a validating parser).

The design of the XML classes follows the SAX2 Java interface, with the names adapted to fit Qt naming conventions. It should be very easy for anybody who has worked with SAX2 to get started with the Qt XML classes.

All readers use the class QXmlInputSource to read the input document. Since you are normally interested in particular content in the XML document, the reader reports the content through special handler classes (QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler and QXmlLexicalHandler), which you must subclass, if you want to process the contents.

Since the handler classes only describe interfaces you must implement all the functions. We provide the QXmlDefaultHandler class to make this easier: it implements a default behavior (do nothing) for all functions, so you can subclass it and just implement the functions you are interested in.

Features and properties of the reader can be set with setFeature() and setProperty() respectively. You can set the reader to use your own subclasses with setEntityResolver(), setDTDHandler(), setContentHandler(), setErrorHandler(), setLexicalHandler() and setDeclHandler(). The parse itself is started with a call to parse().

See also QXmlSimpleReader.

## Method Documentation

### QXmlReader.__init__ (self)

### QXmlReader.__init__ (self, QXmlReader)

### QXmlContentHandler QXmlReader.contentHandler (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the content handler or 0 if none was set.

See also setContentHandler().

### QXmlDeclHandler QXmlReader.declHandler (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the declaration handler or 0 if none was set.

See also setDeclHandler().

### QXmlDTDHandler QXmlReader.DTDHandler (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the DTD handler or 0 if none was set.

See also setDTDHandler().

### QXmlEntityResolver QXmlReader.entityResolver (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the entity resolver or 0 if none was set.

See also setEntityResolver().

### QXmlErrorHandler QXmlReader.errorHandler (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the error handler or 0 if none is set.

See also setErrorHandler().

### (bool, bool ok) QXmlReader.feature (self, QString)

This method is abstract and should be reimplemented in any sub-class.

If the reader has the feature called name, the feature's value is returned. If no such feature exists the return value is undefined.

If ok is not 0: `*`ok is set to true if the reader has the feature called name; otherwise `*`ok is set to false.

See also setFeature() and hasFeature().

### bool QXmlReader.hasFeature (self, QString)

This method is abstract and should be reimplemented in any sub-class.

Returns `true` if the reader has the feature called name; otherwise returns false.

See also feature() and setFeature().

### bool QXmlReader.hasProperty (self, QString)

This method is abstract and should be reimplemented in any sub-class.

Returns true if the reader has the property name; otherwise returns false.

See also property() and setProperty().

### QXmlLexicalHandler QXmlReader.lexicalHandler (self)

This method is abstract and should be reimplemented in any sub-class.

Returns the lexical handler or 0 if none was set.

See also setLexicalHandler().

### bool QXmlReader.parse (self, QXmlInputSource)

This method is abstract and should be reimplemented in any sub-class.

Reads an XML document from input and parses it. Returns true if the parsing was successful; otherwise returns false.

### bool QXmlReader.parse (self, QXmlInputSource)

This method is abstract and should be reimplemented in any sub-class.

### (sip.voidptr, bool ok) QXmlReader.property (self, QString)

This method is abstract and should be reimplemented in any sub-class.

If the reader has the property name, this function returns the value of the property; otherwise the return value is undefined.

If ok is not 0: if the reader has the name property `*`ok is set to true; otherwise `*`ok is set to false.

See also setProperty() and hasProperty().

### QXmlReader.setContentHandler (self, QXmlContentHandler)

This method is abstract and should be reimplemented in any sub-class.

Sets the content handler to handler.

See also contentHandler().

### QXmlReader.setDeclHandler (self, QXmlDeclHandler)

This method is abstract and should be reimplemented in any sub-class.

Sets the declaration handler to handler.

See also declHandler().

### QXmlReader.setDTDHandler (self, QXmlDTDHandler)

This method is abstract and should be reimplemented in any sub-class.

Sets the DTD handler to handler.

See also DTDHandler().

### QXmlReader.setEntityResolver (self, QXmlEntityResolver)

This method is abstract and should be reimplemented in any sub-class.

Sets the entity resolver to handler.

See also entityResolver().

### QXmlReader.setErrorHandler (self, QXmlErrorHandler)

This method is abstract and should be reimplemented in any sub-class.

Sets the error handler to handler. Clears the error handler if handler is 0.

See also errorHandler().

### QXmlReader.setFeature (self, QString, bool)

This method is abstract and should be reimplemented in any sub-class.

Sets the feature called name to the given value. If the reader doesn't have the feature nothing happens.

See also feature() and hasFeature().

### QXmlReader.setLexicalHandler (self, QXmlLexicalHandler)

This method is abstract and should be reimplemented in any sub-class.

Sets the lexical handler to handler.

See also lexicalHandler().

### QXmlReader.setProperty (self, QString, sip.voidptr)

This method is abstract and should be reimplemented in any sub-class.

Sets the property name to value. If the reader doesn't have the property nothing happens.

See also property() and hasProperty().