QXmlReader¶
The
QXmlReader
class provides an interface for XML readers (i.e. parsers). More…
Inherited by: QXmlSimpleReader
Detailed Description¶
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
andQXmlLexicalHandler
), 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()
andsetProperty()
respectively. You can set the reader to use your own subclasses withsetEntityResolver()
,setDTDHandler()
,setContentHandler()
,setErrorHandler()
,setLexicalHandler()
andsetDeclHandler()
. The parse itself is started with a call toparse()
.Note that this class is now deprecated, please use
QXmlStreamReader
orQDomDocument
for reading XML files.See also
- class PySide2.QtXml.QXmlReader¶
- PySide2.QtXml.QXmlReader.DTDHandler()¶
- Return type:
Returns the DTD handler or
None
if none was set.See also
- PySide2.QtXml.QXmlReader.contentHandler()¶
- Return type:
Returns the content handler or
None
if none was set.See also
- PySide2.QtXml.QXmlReader.declHandler()¶
- Return type:
Returns the declaration handler or
None
if none was set.See also
- PySide2.QtXml.QXmlReader.entityResolver()¶
- Return type:
Returns the entity resolver or
None
if none was set.See also
- PySide2.QtXml.QXmlReader.errorHandler()¶
- Return type:
Returns the error handler or
None
if none is set.See also
- PySide2.QtXml.QXmlReader.feature(name)¶
- Parameters:
name – str
- Return type:
PySequence
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 notNone
:*
ok
is set to true if the reader has the feature calledname
; otherwise*
ok
is set to false.See also
- PySide2.QtXml.QXmlReader.hasFeature(name)¶
- Parameters:
name – str
- Return type:
bool
Returns
true
if the reader has the feature calledname
; otherwise returnsfalse
.See also
- PySide2.QtXml.QXmlReader.hasProperty(name)¶
- Parameters:
name – str
- Return type:
bool
Returns
true
if the reader has the propertyname
; otherwise returnsfalse
.See also
- PySide2.QtXml.QXmlReader.lexicalHandler()¶
- Return type:
Returns the lexical handler or
None
if none was set.See also
- PySide2.QtXml.QXmlReader.parse(input)¶
- Parameters:
input –
PySide2.QtXml.QXmlInputSource
- Return type:
bool
- PySide2.QtXml.QXmlReader.parse(input)
- Parameters:
input –
PySide2.QtXml.QXmlInputSource
- Return type:
bool
Reads an XML document from
input
and parses it. Returnstrue
if the parsing was successful; otherwise returnsfalse
.
- PySide2.QtXml.QXmlReader.property(name)¶
- Parameters:
name – str
- Return type:
PySequence
If the reader has the property
name
, this function returns the value of the property; otherwise the return value is undefined.If
ok
is notNone
: if the reader has thename
property*
ok
is set to true; otherwise*
ok
is set to false.See also
- PySide2.QtXml.QXmlReader.setContentHandler(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlContentHandler
Sets the content handler to
handler
.See also
- PySide2.QtXml.QXmlReader.setDTDHandler(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlDTDHandler
Sets the DTD handler to
handler
.See also
- PySide2.QtXml.QXmlReader.setDeclHandler(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlDeclHandler
Sets the declaration handler to
handler
.See also
- PySide2.QtXml.QXmlReader.setEntityResolver(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlEntityResolver
Sets the entity resolver to
handler
.See also
- PySide2.QtXml.QXmlReader.setErrorHandler(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlErrorHandler
Sets the error handler to
handler
. Clears the error handler ifhandler
is 0.See also
- PySide2.QtXml.QXmlReader.setFeature(name, value)¶
- Parameters:
name – str
value – bool
Sets the feature called
name
to the givenvalue
. If the reader doesn’t have the feature nothing happens.See also
- PySide2.QtXml.QXmlReader.setLexicalHandler(handler)¶
- Parameters:
handler –
PySide2.QtXml.QXmlLexicalHandler
Sets the lexical handler to
handler
.See also
- PySide2.QtXml.QXmlReader.setProperty(name, value)¶
- Parameters:
name – str
value –
void
Sets the property
name
tovalue
. If the reader doesn’t have the property nothing happens.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.