Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to check for empty elements (self-closing tags) with QXmlStreamReader?

Is there a way to check for empty elements (self-closing tags) with QXmlStreamReader?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    panosk
    wrote on last edited by
    #1

    Hello all,

    I've been trying to identify empty elements -- that is, I need to check if a tag is self-closing -- with QXmlStreamReader, and make a choice if the tag is indeed self-closing. This is a major problem to my parsing because I can't move forward the parser with readNext(). I miss so much another token type, QXmlStreamReader::EmptyElement...

    Is there a way to achieve this?

    Thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If I'm not mistaken, your use case is described in the StartElement "documentation":http://qt-project.org/doc/qt-5/qxmlstreamreader.html#TokenType-enum

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        panosk
        wrote on last edited by
        #3

        [quote author="SGaist" date="1413152511"]Hi,

        If I'm not mistaken, your use case is described in the StartElement "documentation":http://qt-project.org/doc/qt-5/qxmlstreamreader.html#TokenType-enum[/quote]

        Hello,

        Thanks for your reply.

        Well, this is actually my problem. StartElement reports both elements with content and empty elements, but my app logic requires a distinction. I need to represent some tags, attributes, and text into a QString-like format, process them in another component, and later I need to reconstruct the original xml file. It's some kind of a generic xml parser. I have made some progress using QXmlStreamWriter, so maybe the solution is not far. Still, it would be nice if there was a QXmlStreamReader::EmptyElement token type.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved