Ceaser88
22nd July 2011, 15:41
I am trying to read the text in between xml tags using a simple QXmlStreamReader
i have filled a QXmlStreamReader called sectionReader with xml from this link:http://www.waseet.net/apps/iphone/xml/categories-file.xml
this code shows all start elements normally:
void MainWindow::parseXml2()
{
while (!sectionReader.atEnd())
{
sectionReader.readNext();
if(sectionReader.isStartElement())
{
ui->textEdit->append(sectionReader.name().toString());
}
}
}
whereas this code gives whitespaces:
void MainWindow::parseXml2()
{
while (!sectionReader.atEnd())
{
sectionReader.readNext();
if(sectionReader.isStartElement())
{
ui->textEdit->append(sectionReader.readElementText());
}
}
}
can anyone indicate what is going wrong? why aren't i reading any text in between the start and end tags?
I can verify that the xml has text in between the tags. here is the link if anyone wants to check: http://www.waseet.net/apps/iphone/xml/categories-file.xml
i have attached my .h and .cpp files along with the post
i have filled a QXmlStreamReader called sectionReader with xml from this link:http://www.waseet.net/apps/iphone/xml/categories-file.xml
this code shows all start elements normally:
void MainWindow::parseXml2()
{
while (!sectionReader.atEnd())
{
sectionReader.readNext();
if(sectionReader.isStartElement())
{
ui->textEdit->append(sectionReader.name().toString());
}
}
}
whereas this code gives whitespaces:
void MainWindow::parseXml2()
{
while (!sectionReader.atEnd())
{
sectionReader.readNext();
if(sectionReader.isStartElement())
{
ui->textEdit->append(sectionReader.readElementText());
}
}
}
can anyone indicate what is going wrong? why aren't i reading any text in between the start and end tags?
I can verify that the xml has text in between the tags. here is the link if anyone wants to check: http://www.waseet.net/apps/iphone/xml/categories-file.xml
i have attached my .h and .cpp files along with the post