xmlqtqxmlstreamreader

QXmlStreamReader::isEndElement() returning false


Why is QXmlStreamReader::isEndElement() returning false when it encounters something like <element/> and how can I recognize an <element/>?


Solution

  • If an empty element <element/> is parsed you should see a StartElement token immediately followed by a EndElement token:

    The reader reports the start of an element with namespaceUri() and name(). Empty elements are also reported as StartElement, followed directly by EndElement.

    But calling QXmlStreamReader::isEndElement() will always return false if positioned on a StartElement token, even if the element is empty.