QXmlReader

Inheritance diagram of QXmlReader

Synopsis

Functions

def DTDHandler ()
def contentHandler ()
def declHandler ()
def entityResolver ()
def errorHandler ()
def feature (name)
def hasFeature (name)
def hasProperty (name)
def lexicalHandler ()
def parse (input)
def parse (input)
def property (name)
def setContentHandler (handler)
def setDTDHandler (handler)
def setDeclHandler (handler)
def setEntityResolver (handler)
def setErrorHandler (handler)
def setFeature (name,value)
def setLexicalHandler (handler)
def setProperty (name,value)

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 QXmlReader.setFeature() and QXmlReader.setProperty() respectively. You can set the reader to use your own subclasses with QXmlReader.setEntityResolver() , QXmlReader.setDTDHandler() , QXmlReader.setContentHandler() , QXmlReader.setErrorHandler() , QXmlReader.setLexicalHandler() and QXmlReader.setDeclHandler() . The parse itself is started with a call to QXmlReader.parse() .

See also

QXmlSimpleReader

class PySide.QtXml.QXmlReader
QXmlReader.DTDHandler()
Return type:QXmlDTDHandler

Returns the DTD handler or 0 if none was set.

QXmlReader.contentHandler()
Return type:QXmlContentHandler

Returns the content handler or 0 if none was set.

QXmlReader.declHandler()
Return type:QXmlDeclHandler

Returns the declaration handler or 0 if none was set.

QXmlReader.entityResolver()
Return type:QXmlEntityResolver

Returns the entity resolver or 0 if none was set.

QXmlReader.errorHandler()
Return type:QXmlErrorHandler

Returns the error handler or 0 if none is set.

QXmlReader.feature(name)
Parameter:name – QString
Return type:bool

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.

QXmlReader.hasFeature(name)
Parameter:name – QString
Return type:bool

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

QXmlReader.hasProperty(name)
Parameter:name – QString
Return type:bool

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

QXmlReader.lexicalHandler()
Return type:QXmlLexicalHandler

Returns the lexical handler or 0 if none was set.

QXmlReader.parse(input)
Parameter:input – QXmlInputSource
Return type:bool

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

QXmlReader.parse(input)
Parameter:input – QXmlInputSource
Return type:bool

Parses the given input .

QXmlReader.property(name)
Parameter:name – QString
Return type:void

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.

QXmlReader.setContentHandler(handler)
Parameter:handler – QXmlContentHandler

Sets the content handler to handler .

QXmlReader.setDTDHandler(handler)
Parameter:handler – QXmlDTDHandler

Sets the DTD handler to handler .

QXmlReader.setDeclHandler(handler)
Parameter:handler – QXmlDeclHandler

Sets the declaration handler to handler .

QXmlReader.setEntityResolver(handler)
Parameter:handler – QXmlEntityResolver

Sets the entity resolver to handler .

QXmlReader.setErrorHandler(handler)
Parameter:handler – QXmlErrorHandler

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

QXmlReader.setFeature(name, value)
Parameters:
  • name – QString
  • value – bool

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

QXmlReader.setLexicalHandler(handler)
Parameter:handler – QXmlLexicalHandler

Sets the lexical handler to handler .

QXmlReader.setProperty(name, value)
Parameters:
  • name – QString
  • value – void

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