QXmlReader Class▲
-
Header: QXmlReader
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Core5Compat)
target_link_libraries(mytarget PRIVATE Qt6::Core5Compat)
-
qmake: QT += core5compat
-
Inherited By: QXmlSimpleReader
-
Group: QXmlReader is part of xml-tools
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 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().
Note that this class is now deprecated, please use QXmlStreamReader or QDomDocument for reading XML files.
See Also▲
See also QXmlSimpleReader
Member Function Documentation▲
[virtual] QXmlReader::~QXmlReader()▲
Destroys the reader.
[pure virtual] QXmlDTDHandler *QXmlReader::DTDHandler() const▲
[pure virtual] QXmlContentHandler *QXmlReader::contentHandler() const▲
[pure virtual] QXmlDeclHandler *QXmlReader::declHandler() const▲
[pure virtual] QXmlEntityResolver *QXmlReader::entityResolver() const▲
[pure virtual] QXmlErrorHandler *QXmlReader::errorHandler() const▲
[pure virtual] bool QXmlReader::feature(const QString &name, bool *ok = nullptr) const▲
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 nullptr: *ok is set to true if the reader has the feature called name; otherwise *ok is set to false.
See Also▲
See also setFeature(), hasFeature()
[pure virtual] bool QXmlReader::hasFeature(const QString &name) const▲
Returns true if the reader has the feature called name; otherwise returns false.
See Also▲
See also feature(), setFeature()
[pure virtual] bool QXmlReader::hasProperty(const QString &name) const▲
Returns true if the reader has the property name; otherwise returns false.
See Also▲
See also property(), setProperty()
[pure virtual] QXmlLexicalHandler *QXmlReader::lexicalHandler() const▲
[pure virtual] bool QXmlReader::parse(const QXmlInputSource *input)▲
Reads an XML document from input and parses it. Returns true if the parsing was successful; otherwise returns false.
[pure virtual] void *QXmlReader::property(const QString &name, bool *ok = nullptr) const▲
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 nullptr: if the reader has the name property *ok is set to true; otherwise *ok is set to false.
See Also▲
See also setProperty(), hasProperty()
[pure virtual] void QXmlReader::setContentHandler(QXmlContentHandler *handler)▲
[pure virtual] void QXmlReader::setDTDHandler(QXmlDTDHandler *handler)▲
[pure virtual] void QXmlReader::setDeclHandler(QXmlDeclHandler *handler)▲
[pure virtual] void QXmlReader::setEntityResolver(QXmlEntityResolver *handler)▲
[pure virtual] void QXmlReader::setErrorHandler(QXmlErrorHandler *handler)▲
Sets the error handler to handler. Clears the error handler if handler is 0.
See Also▲
See also errorHandler()
[pure virtual] void QXmlReader::setFeature(const QString &name, bool value)▲
Sets the feature called name to the given value. If the reader doesn't have the feature nothing happens.
See Also▲
See also feature(), hasFeature()
[pure virtual] void QXmlReader::setLexicalHandler(QXmlLexicalHandler *handler)▲
[pure virtual] void QXmlReader::setProperty(const QString &name, void *value)▲
Sets the property name to value. If the reader doesn't have the property nothing happens.
See Also▲
See also property(), hasProperty()
Obsolete Members for QXmlReader▲
The following members of class QXmlReader are deprecated. We strongly advise against using them in new code.
Obsolete Member Function Documentation▲
[pure virtual] bool QXmlReader::parse(const QXmlInputSource &input)▲
This function is deprecated. We strongly advise against using it in new code.
Parses the given input.