title: Qt XmlQuery subquery attribute
body: <p>I am trying to parse a gpx file using QXmlQuery (Qt 5.0).</p>
  
  <p>The idea is to gather all the trkpt elements, and then subquery each element in order to extract latitude, longitude, altitude...</p>
  
  <p>The problem is that it seems to not recognize the attribute name, because this code works:</p>
  
  <pre><code>query.setQuery
          (
              "declare default element namespace \"http://www.topografix.com/GPX/1/1\";"
              "declare variable $gpxFile external;"
              "doc($gpxFile)//trkpt"
          );
  
  if(query.isValid())
  {
      QXmlResultItems trkpts;
      query.evaluateTo(&amp;trkpts);
      for(QXmlItem trkpt = trkpts.next(); !trkpt.isNull(); trkpt = trkpts.next())
      {
          QXmlQuery childQuery;
          QStringList res;
  
          childQuery.setFocus(trkpt);
          childQuery.setQuery
                  (
                      "@*/string()"
                  ); // &lt;------------------------- this prints out all the attributes
  
          childQuery.evaluateTo(&amp;res);
          qDebug() &lt;&lt; res &lt;&lt; "\n";
      }
  }
  </code></pre>
  
  <p>while this one does not:</p>
  
  <pre><code>        // ... same code as above
          childQuery.setQuery
                  (
                      "@lat/string()"
                  ); // &lt;------------------------- this prints out only a \n
          // ... same code as above
  </code></pre>
  
  <p>any idea about what is wrong?</p>
  
  <p>Please note that if I try to gather all the @lat attributes using the "outer" query, it works as expected:</p>
  
  <pre><code>query.setQuery
          (
              "declare default element namespace \"http://www.topografix.com/GPX/1/1\";"
              "declare variable $gpxFile external;"
              "doc($gpxFile)//trkpt/@lat/string()"
          );
  </code></pre>
  
  <p><b>EDIT</b></p>
  
  <p>This is a gpx sample file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?&gt;
  &lt;gpx
      version="1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.topografix.com/GPX/1/0"
      xmlns:topografix="http://www.topografix.com/GPX/Private/TopoGrafix/0/2"
      xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/Private/TopoGrafix/0/2 http://www.topografix.com/GPX/Private/TopoGrafix/0/2/topografix.xsd"&gt;
      &lt;trk&gt;
          &lt;name&gt;My track&lt;/name&gt;
          &lt;desc&gt;My track description&lt;/desc&gt;
          &lt;trkseg&gt;
              &lt;trkpt lat="38.919839863" lon="-121.020112049"&gt;
                  &lt;ele&gt;265.447754&lt;/ele&gt;
                  &lt;time&gt;2003-02-05T18:19:20Z&lt;/time&gt;
              &lt;/trkpt&gt;
              &lt;trkpt lat="38.919796947" lon="-121.020240795"&gt;
                  &lt;ele&gt;264.967041&lt;/ele&gt;
                  &lt;time&gt;2003-02-05T18:19:20Z&lt;/time&gt;
              &lt;/trkpt&gt;
              &lt;trkpt lat="38.919861320" lon="-121.020498287"&gt;
                  &lt;ele&gt;263.044434&lt;/ele&gt;
                  &lt;time&gt;2003-02-05T18:19:20Z&lt;/time&gt;
              &lt;/trkpt&gt;
              &lt;trkpt lat="38.919990066" lon="-121.020798694"&gt;
                  &lt;ele&gt;263.525146&lt;/ele&gt;
                  &lt;time&gt;2003-02-05T18:19:20Z&lt;/time&gt;
              &lt;/trkpt&gt;
          &lt;/trkseg&gt;
      &lt;/trk&gt;
  &lt;/gpx&gt;
  </code></pre>
  
  <p><b>EDIT</b></p>
  
  <p>I found a workaround for this problem, by using QDomDocument instead of QXmlQuery.
  The result looks like the code below (<b>all error checks removed for sake of brevity</b>):</p>
  
  <pre><code>QFile file = ("mytrack.gpx");
  file.open(QIODevice::ReadOnly);
  
  QDomDocument doc("mydoc");
  doc.setContent(&amp;file);
  
  QDomElement root = doc.documentElement();
  QDomNodeList trkpts = root.elementsByTagName("trkpt");
  
  for(int i = 0; i &lt; trkpts.length(); i++)
  {
      QDomElement e = trkpts.at(i).toElement();
  
      QString latitude = e.attribute("lat");
      QString longitude = e.attribute("lon");
  
      QDomNodeList elevation_list = e.elementsByTagName("ele");
      QString elevation = elevation_list.at(0).toElement().text();
  
      // ... and so on
  }
  </code></pre>
  
  <p>I would like to find a solution to this problem by using QXmlQuery, but in the meantime this just works.</p>