PDA

View Full Version : QXmlStreamReader problems



rishid
19th January 2008, 03:31
Edit: Please ignore, I am an idiot and realized I was only checking if the file exists and not actually opening the file. :rolleyes:

I am trying to use the new QXmlStreamReader available in Qt 4.3. Even with this simple code, I keep getting an error. The error is QXmlStreamReader::PrematureEndOfDocumentError. Which is described as
The input stream ended before the document was parsed completely. This error can be recovered from.

Anyone have any idea on why this is happening / how to recover from it?

the deb() method is just something I use to print text to a label.



QFile file("settings.xml");

if (file.exists())
{
QXmlStreamReader xmlReader( &file );

while ( !xmlReader.atEnd() ) {
xmlReader.readNext();
deb(xmlReader.errorString());
}
if (xmlReader.hasError()) {
deb("error occured");
}
}


Settings.xml is shown below (created by a QXmlStreamWriter):

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<alarm>0</alarm>
<events>0</events>
<privacy>0</privacy>
<backlight>0</backlight>
</settings>

Niels Holst
26th June 2008, 11:34
I am having the exact same problem. Did you ever find a solution?
Niels.

mcosta
26th June 2008, 11:43
You have to open the file before use QXmlStreamReader