[Qt-interest] "Premature end of document" error while reading xml file
Xinyi Li
lixinyi.qt at gmail.com
Tue Aug 11 04:37:32 CEST 2009
Dear list
I'm new to XML
I'm just running some sample code to read a xml file but got the
"Premature end of document " error and I don't know why
Here's the XML file I wanted to read(a very short one)
<<node.xml>>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpyÆ -->
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
And here's my Code:
------------------code start -----------
#include <QApplication>
#include <QMainWindow>
#include <QFile>
#include <QXmlStreamReader>
#include <QDebug>
int main( int argc, char** argv ) {
QApplication a(argc,argv);
QMainWindow window;
QFile file("node.xml");
QXmlStreamReader reader(&file);
while( !reader.atEnd() ) {
reader.readNext();
if( reader.error() ) {
qDebug() << reader.errorString() <<
QString::number(reader.lineNumber()) <<
QString::number(reader.columnNumber());
}
}
window.resize(400,300);
window.show();
return a.exec();
}
----------------end of code -------------------
And here's the message I got in Debugger Console (I'm a Mac user)
The Debugger has exited with status 0.
[Session started at 2009-08-11 11:17:34 +0900.]
"Premature end of document." "1" "0"
what should I do?
Please help me!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090811/6f31db2e/attachment.html
More information about the Qt-interest-old
mailing list