I\'m trying to figure out how QXmlStreamReader works for a C++ application I\'m writing. The XML file I want to parse is a large dictionary with a convoluted structure and plent
I'm answering this myself as this problem was related to three issues, two of which were brought up by the responses.
The relevant code section that works as expected now looks like this:
while (!xml.atEnd() && !xml.hasError())
{
xml.readNext();
if (xml.isStartElement())
{
QString name = xml.name().toString();
if (name == "firstname" || name == "surname" ||
name == "email" || name == "website")
{
cout << "element name: '" << name << "'"
<< ", text: '" << xml.readElementText()
<< "'" << endl;
}
}
}
if (xml.hasError())
{
cout << "XML error: " << xml.errorString() << endl;
}
else if (xml.atEnd())
{
cout << "Reached end, done" << endl;
}