Results 1 to 2 of 2

Thread: QXmlStreamReader error on reading empty element

  1. #1
    Join Date
    Jul 2012
    Posts
    228
    Thanks
    19
    Thanked 14 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QXmlStreamReader error on reading empty element

    When i parse an XML document using the QXmlStreamReader class, i am presented with an error if i call "readElementText()" on an empty element and my parsing is interrupted. The error is:
    Expected character data.
    Apparently, this is expected behavior.

    So how can i know whether an element is empty or not?

  2. The following user says thank you to tuli for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader error on reading empty element

    Some ideas:

    - Call readNext() and check if the token is Charactes, i.e. isCharacters() returns true
    - Check if calling isEndElement() is true

    Cheers,
    _

Similar Threads

  1. Reading and rereading a file with QXmlStreamReader
    By TheRonin in forum Qt Programming
    Replies: 14
    Last Post: 30th April 2015, 15:04
  2. Replies: 9
    Last Post: 22nd February 2013, 13:27
  3. Replies: 9
    Last Post: 23rd April 2012, 14:53
  4. QXmlStreamReader not reading text within tags
    By Ceaser88 in forum Newbie
    Replies: 2
    Last Post: 24th July 2011, 11:06
  5. Replies: 0
    Last Post: 26th May 2010, 20:01

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.