Is there a way to check for empty elements (self-closing tags) with QXmlStreamReader?
-
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.
-
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 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.