Answer the question
In order to leave comments, you need to log in
How to parse xml using QXmlStreamReader in Qt?
There is such an xml file with the following structure:
<?xml version="1.0" encoding="windows-1251"?>
<FileIndex>
<Name>lol.xml</Name>
<Size>0</Size>
<Path>E:/test/build-untitled-Desktop_Qt_5_4_1_MinGW_32bit-Release/lol.xml</Path>
<Created>Сб мар 14 21:55:37 2015</Created>
<Name>Makefile</Name>
<Size>20399</Size>
<Path>E:/test/build-untitled-Desktop_Qt_5_4_1_MinGW_32bit-Release/Makefile</Path>
<Created>Чт мар 12 19:00:45 2015</Created>
</FileIndex>
while(!xmlReader.atEnd())
{
QXmlStreamReader::TokenType token = xmlReader.readNext();
if(token == QXmlStreamReader::StartElement) {
if(xmlReader.name() == "Name") {
xmlReader.readNext();
ui->textBrowser->setText(xmlReader.text().toString());
}
}
}
Answer the question
In order to leave comments, you need to log in
I dare to assume that all are displayed, but very quickly and at the end there is only one, the last one, which you see. This line is ui->textBrowser->setText(xmlReader.text().toString()); overwrites the previous value and inserts the new one. Use the append() method and then everything will appear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question