Results 1 to 3 of 3

Thread: QXmlStreamReader problems

  1. #1
    Join Date
    Jan 2008
    Posts
    27
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QXmlStreamReader problems

    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.

    Qt Code:
    1. QFile file("settings.xml");
    2.  
    3. if (file.exists())
    4. {
    5. QXmlStreamReader xmlReader( &file );
    6.  
    7. while ( !xmlReader.atEnd() ) {
    8. xmlReader.readNext();
    9. deb(xmlReader.errorString());
    10. }
    11. if (xmlReader.hasError()) {
    12. deb("error occured");
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    Settings.xml is shown below (created by a QXmlStreamWriter):
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <settings>
    3. <alarm>0</alarm>
    4. <events>0</events>
    5. <privacy>0</privacy>
    6. <backlight>0</backlight>
    7. </settings>
    To copy to clipboard, switch view to plain text mode 
    Last edited by rishid; 19th January 2008 at 03:49.

  2. #2
    Join Date
    Jun 2008
    Location
    Denmark
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QXmlStreamReader problems

    I am having the exact same problem. Did you ever find a solution?
    Niels.

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader problems

    You have to open the file before use QXmlStreamReader
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 2
    Last Post: 8th March 2007, 22:22
  2. problems i faced with QT-3
    By jineesh in forum Newbie
    Replies: 4
    Last Post: 4th January 2007, 14:44
  3. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33
  4. Utf8 problems
    By cristiano in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2006, 00:14
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.