Hello!

I'm trying to parse xml document:
Qt Code:
  1. <xml_api_reply version="1">
  2. <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
  3.  
  4. <forecast_information>
  5. <city data="Gdansk, Pomerania"/>
  6. <postal_code data="Gdansk,Poland"/>
  7. <latitude_e6 data=""/>
  8. <longitude_e6 data=""/>
  9. <forecast_date data="2010-12-09"/>
  10. <current_date_time data="2010-12-09 23:00:00 +0000"/>
  11. <unit_system data="SI"/>
  12. </forecast_information>
  13.  
  14. <current_conditions>
  15. <condition data="Zachmurzenie"/>
  16. <temp_f data="30"/>
  17. <temp_c data="-1"/>
  18. <humidity data="Wilgotność: 86%"/>
  19. <icon data="/ig/images/weather/cloudy.gif"/>
  20. <wind_condition data="Wiatr: płn.-zach. z szybkością 26 km/h"/>
  21. </current_conditions>
  22. [...]
To copy to clipboard, switch view to plain text mode 

My code:
Qt Code:
  1. ByteArray newData = NetRepl->read(2048);
  2.  
  3. out << newData << endl;
  4.  
  5. QXmlStreamReader xmlStream(newData);
  6. while(!xmlStream.atEnd())
  7. {
  8. xmlStream.readNext();
  9. if(xmlStream.isStartElement())
  10. {
  11. QString sec(xmlStream.name().toString());
  12. out << sec << endl;
  13.  
  14. while (!xmlStream.isEndElement())
  15. {
  16. xmlStream.readNext();
  17. QString sec(xmlStream.name().toString());
  18. out << "***" << sec << endl;
  19.  
  20. QXmlStreamAttributes attrs = xmlStream.attributes();
  21. out << attrs.value("data").toString() << endl;
  22. }
  23. }
  24. }
To copy to clipboard, switch view to plain text mode 

And it sometimes returns "data" correctly, and sometimes it's empty:

Qt Code:
  1. xml_api_reply
  2. ***weather
  3.  
  4. ***forecast_information
  5.  
  6. ***city
  7. Gdansk, Pomerania //OK
  8. ***city
  9.  
  10. postal_code
  11. ***postal_code
  12.  
  13. latitude_e6
  14. ***latitude_e6
  15.  
  16. longitude_e6
  17. ***longitude_e6
  18.  
  19. forecast_date
  20. ***forecast_date
  21.  
  22. current_date_time
  23. ***current_date_time
  24.  
  25. unit_system
  26. ***unit_system
  27.  
  28. current_conditions
  29. ***condition
  30. Zachmurzenie //OK
  31. ***condition
  32.  
  33. temp_f
  34. ***temp_f
  35.  
  36. temp_c
  37. ***temp_c
  38.  
  39. humidity
  40. ***humidity
  41.  
  42. icon
  43. ***icon
  44.  
  45. wind_condition
  46. ***wind_condition
To copy to clipboard, switch view to plain text mode 

How should I do It correctly?

thanks in advance
best regards
Tomasz