Cannot read second XML element

  • The question is:

    I have the following XML file which I believe is valid XML:

    <?xml version="1.0" encoding="UTF-8"?>

    and have the following code to read it:

    QString settingsFile = settingsDir + "/QBoardSettings.xml";
        QFile file(settingsFile); | QIODevice::Text);
        QXmlStreamReader xmlStreamReader(&file);
        while (xmlStreamReader.readNextStartElement()) {
                QString s =;

    But this code prints only "Style" instead of printing names for both elements. What I am doing wrong? Thanks in advance.

  • Hi @fire_lizard

    Instead of using readNextStartElement() in While loop, use atEnd() method to parse the xml file till end.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.