title: QXMLStreamReader is skipping over text elements
body: <p>I am writing out an XML file with some data. Later I want to read the XML file and use the data in my program. However, when I read it back in, QXMLStreamReader seems to be skipping over some child elements.</p>
  
  <p>Here is a snip from my XML file:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;TEMPROOT&gt;
      &lt;Parent1&gt;
          &lt;C0&gt;238.195|1401.12&lt;/C0&gt;
          &lt;C1&gt;795.475|1087.65&lt;/C1&gt;
          &lt;C2&gt;995.748|756.766&lt;/C2&gt;
      &lt;/Parent1&gt;
      &lt;Parent2&gt;
          &lt;left&gt;248&lt;/left&gt;
          &lt;right&gt;671&lt;/right&gt;
          &lt;Width&gt;496&lt;/Width&gt;
          &lt;Height&gt;583&lt;/Height&gt;
      &lt;/Parent2&gt;
      &lt;Parent3&gt;
          &lt;Number&gt;9&lt;/Number&gt;
          &lt;Blue&gt;4&lt;/Blue&gt;
          &lt;Red&gt;5&lt;/Red&gt;
      &lt;/Parent3&gt;
  &lt;/TEMPROOT&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It reads Parent1 and its children correctly. My code recognizes Parent2, but skips over its children and goes directly for Parent3 where it reads its children correctly.</p>
  
  <p>Here is my code where I <em>WRITE</em> out the XML:</p>
  
  <pre><code>QXmlStreamWriter xmlWriter(&amp;file);
  xmlWriter.setAutoFormatting(true);
  xmlWriter.writeStartDocument();
  xmlWriter.writeStartElement("TEMPROOT");
  
  xmlWriter.writeStartElement("Parent1");
  xmlWriter.writeTextElement("C0", str0);
  xmlWriter.writeTextElement("C1", str1);
  xmlWriter.writeTextElement("C2", str2);
  xmlWriter.writeEndElement();
  
  xmlWriter.writeStartElement("Parent2");
  xmlWriter.writeTextElement("left", QString::number(rectCoord[0]));
  xmlWriter.writeTextElement("right", QString::number(rectCoord[1]));
  xmlWriter.writeTextElement("Width", QString::number(rectCoord[2]));
  xmlWriter.writeTextElement("Height", QString::number(rectCoord[3]));
  xmlWriter.writeEndElement();
  
  xmlWriter.writeStartElement("Parent3");
  xmlWriter.writeTextElement("Number", strNum);
  xmlWriter.writeTextElement("Blue", strBlue);
  xmlWriter.writeTextElement("Red", strRed);
  xmlWriter.writeEndElement();
  
  xmlWriter.writeEndElement();
  xmlWriter.writeEndDocument();
  </code></pre>
  
  <p>Here is how I <em>READ</em> in the XML file:</p>
  
  <pre><code>QXmlStreamReader xmlReader(&amp;file);
  QVector&lt;QString&gt; Qv1;
  QVector&lt;double&gt; QV2;
  QVector&lt;QString&gt; Qv3;
  while (!xmlReader.isEndDocument())
  {
      xmlReader.readNext();
      QString Name = xmlReader.name().toString();
      if (Name == "Parent1")
      {
          while (xmlReader.name().toString() != "Parent2")
          {
              if (xmlReader.name().toString().at(0) == "C")
              {
                  QV1.append(xmlReader.readElementText());
              }
              xmlReader.readNext();
          }
       }
       else if (Name == "Parent2")
      {
          while (xmlReader.name().toString() != "Parent3")
          {
              if (xmlReader.name().toString() == "left")
              {
                  QV2.append(xmlReader.readElementText().toDouble());
              }
              else if (xmlReader.name().toString() == "right")
              {
                  QV2.append(xmlReader.readElementText().toDouble());
              }
              else if (xmlReader.name().toString() == "Width")
              {
                  QV2.append(xmlReader.readElementText().toDouble());
              }
              else if (xmlReader.name().toString() == "Height")
              {
                  QV2.append(xmlReader.readElementText().toDouble());
              }
              xmlReader.readNext();
  
          }
      }
      else if (Name == "Number")
      {
          Qv3.append(xmlReader.readElementText());
      }
      else if (Name == "Blue")
      {
          Qv3.append(xmlReader.readElementText());
      }
      else if (Name == "Red")
      {
          Qv3.append(xmlReader.readElementText());
      }
  }
  </code></pre>
  
  <p>The <strong>MAIN</strong> issue is that the <code>Name</code> variable, which is the name of the current XML element on <code>xmlReader</code> goes from <code>Parent2</code> straight to <code>Parent3</code> ignoring the children of <code>Parent2</code>. The children of <code>Parent1</code> and <code>Parent3</code> are being read in with no problems. Am I doing something wrong when I read or write the xml? </p>