The question is:
I have the following XML file which I believe is valid XML:
<?xml version="1.0" encoding="UTF-8"?>
<Style>3</Style>
<GameVariant>5</GameVariant>
<?xml version="1.0" encoding="UTF-8"?>
<Style>3</Style>
<GameVariant>5</GameVariant>
To copy to clipboard, switch view to plain text mode
and have the following code to read it:
QString settingsFile
= settingsDir
+ "/QBoardSettings.xml";
QFile file(settingsFile
);
QXmlStreamReader xmlStreamReader(&file);
while (xmlStreamReader.readNextStartElement()) {
QString s
= xmlStreamReader.
name().
toString();
qDebug(qPrintable(s));
}
QString settingsFile = settingsDir + "/QBoardSettings.xml";
QFile file(settingsFile);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QXmlStreamReader xmlStreamReader(&file);
while (xmlStreamReader.readNextStartElement()) {
QString s = xmlStreamReader.name().toString();
qDebug(qPrintable(s));
}
To copy to clipboard, switch view to plain text mode
But this code prints only "Style" instead of printing names for both elements. What I am doing wrong? Thanks in advance.
Bookmarks