Edit: Please ignore, I am an idiot and realized I was only checking if the file exists and not actually opening the file. 
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");
}
}
QFile file("settings.xml");
if (file.exists())
{
QXmlStreamReader xmlReader( &file );
while ( !xmlReader.atEnd() ) {
xmlReader.readNext();
deb(xmlReader.errorString());
}
if (xmlReader.hasError()) {
deb("error occured");
}
}
To copy to clipboard, switch view to plain text mode
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>
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<alarm>0</alarm>
<events>0</events>
<privacy>0</privacy>
<backlight>0</backlight>
</settings>
To copy to clipboard, switch view to plain text mode
Bookmarks