title: Cannot identify empty Elements with QXmlStreamReader
body: <p>I have some trouble detecting empty elements using the Qt QXmlStreamReader (Qt 4.8.1).
  There is an XML file that has the following section</p>
  
  <pre><code>&lt;Groups Number="4"&gt;
    &lt;Group Id="0" GroupName="Chambers"&gt;
      &lt;MemberChannels&gt;4,5,6,7,8,9,10,11&lt;/MemberChannels&gt;
      &lt;AverageShown&gt;true&lt;/AverageShown&gt;
    &lt;/Group&gt;
    &lt;Group Id="1" GroupName="Fluids"&gt;
      &lt;MemberChannels&gt;0,1,17,18&lt;/MemberChannels&gt;
      &lt;AverageShown&gt;false&lt;/AverageShown&gt;
    &lt;/Group&gt;
    &lt;Group Id="2"/&gt;
    &lt;Group Id="3"/&gt;
  &lt;/Groups&gt;
  </code></pre>
  
  <p>As you can see, the elements with the Id 2 and 3 are empty except the attribute. The attribute doesn't change anything. If it's not in the element, the problem still occurs.</p>
  
  <p>This is the parsing code using QXmlStreamReader, I simplified it, so it may not compile. It is just that you get the basic idea.</p>
  
  <pre><code>[...]
  QXmlStreamReader* m_poStreamReader = new QXmlStreamReader;
  [...]
  
  if(m_poStreamReader-&gt;readNextStartElement() &amp;&amp; m_poStreamReader-&gt;name().toString() == "Group") {
    this-&gt;parseGroupElement();
  }
  
  [...]
  
  bool CTempscanXmlParser::parseGroupElement( void ) {
    TGroupElement tElement;
    if(m_poStreamReader-&gt;isStartElement() &amp;&amp; !m_poStreamReader-&gt;isEndElement()) { // not empty
      TGroupElement tElement = this-&gt;readGroupElement();
    } else if(m_poStreamReader-&gt;isStartElement() &amp;&amp; m_poStreamReader-&gt;isEndElement()) { // empty
      tElement.oGroupName = QString::null;
    }
    [...]
  }
  </code></pre>
  
  <p>The documentation says: </p>
  
  <blockquote>
    <p>Empty elements are also reported as StartElement, followed directly by EndElement.</p>
  </blockquote>
  
  <p>I can use readNext() and still not receive an end element. It seems like the parser is only able to detect</p>
  
  <pre><code>&lt;tag&gt;&lt;/tag&gt;
  </code></pre>
  
  <p>as an empty element but not</p>
  
  <pre><code>&lt;tag/&gt;
  </code></pre>
  
  <p>So, is it just me or does the problem exist in Qt? And if so, how can I detect empty elements that do not consist of 2 seperated elements (start/end)?</p>
  
  <p><strong>Edit:</strong>
  So Huytard asked me for a working example. But his answer lead me to a solution that almost answered my question. Therefore I put a clarified example in my answer.</p>