November 2014
Beginner to intermediate
264 pages
5h 32m
English
Earlier versions of Qt had a number of XML parsers, each suited to different tasks and different styles of parsing. Fortunately, in Qt 5, this has been streamlined; the key XML parser to use is the QXmlStreamReader class (see http://qt-project.org/doc/qt-5/qxmlstreamreader.html for details). This class reads from a QIODevice subclass and reads XML tags one at a time, letting you switch on the type of tag the parser encounters. Thus, our parser looks something like this:
QXmlStreamReader xml;
xml.setDevice(input);
while (!xml.atEnd()) {
QXmlStreamReader::TokenType type = xml.readNext();
switch(type)
{
... // do processing
}
}
if (xml.hasError()) {
... // do error handling
}The QXMLStreamReader class reads each tag of the XML ...
Read now
Unlock full access