I need to read an XML file in order to accomplish my task. I can read it using the example i found in mine Nokia QT SDK. But if i try to modify it a little bit - it doesn't work. Here is the parseXml function i have:
void List:: parseXml()
Qt Code:
  1. {
  2. int a = 0;
  3. while (!xml.atEnd())
  4. {
  5. xml.readNext();
  6. if (xml.isStartElement())
  7. {
  8. currentTag = xml.name().toString();
  9. }
  10. else if (xml.isEndElement())
  11. {
  12. if (xml.name() == "movie")
  13. {
  14.  
  15. listWidget->insertItem(a, "");
  16. listWidget->setItemWidget(listWidget->item(a), new Custom_Widget(titleString, dateString, aboutString, pictureString));
  17. listWidget->item(a)->setSizeHint(QSize (350,470));
  18. listWidget->setSpacing(1);
  19. titleString.clear();
  20. dateString.clear();
  21. aboutString.clear();
  22. pictureString.clear();
  23. a = a + 1;
  24. }
  25.  
  26. }
  27. else if (xml.isCharacters() && !xml.isWhitespace())
  28. {
  29. if (currentTag == "title")
  30. titleString += xml.text().toString();
  31. else if (currentTag == "globalReleaseDate")
  32. dateString += xml.text().toString();
  33. else if (currentTag == "annotation")
  34. aboutString += xml.text().toString();
  35. else if (currentTag == "imageType1")
  36. pictureString += xml.text().toString();
  37. }
  38. }
  39. if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
  40. {
  41. qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
  42. http.abort();
  43. }
  44. }
To copy to clipboard, switch view to plain text mode 

This code works on this page:
http://www.forumcinemas.lv/rss/xml/movies/

But now i want to make it work on other pages (the ones that usually contain items not movies). I tried to adjust this function to define the type of XML by the first tag in the file (here i was trying to make function to find tag "movieList". Unfortunately, the function does not complete the task. It finds only 2 movies (of 20) and then stops. Could someone please advice, how to change this function, so that it would work as i want (whole function works only if it finds the "movieList" tag).