hi,

I'm trying to parse XML file with SAX, but my program started looping. Here is my function:
Qt Code:
  1. void JTemplate::readStyles(QXmlStreamReader &xml, QString parentId, QString id, JList<JCss> &css)
  2. {
  3. if (xml.name() == parentId)
  4. {
  5. qDebug()<<"Parsuje: "<<parentId;
  6.  
  7. while (!(xml.name() == parentId && xml.tokenType() == QXmlStreamReader::EndElement))
  8. {
  9. xml.readNext();
  10.  
  11. JCss _result;
  12. _result.setName(xml.attributes().value("name").toString());
  13. qDebug()<<"Nazwa stylu Css to: "<<_result.getName();
  14. xml.readNext();
  15.  
  16. while (!(xml.name() == id && xml.tokenType() == QXmlStreamReader::EndElement))
  17. {
  18. qDebug()<<"Styl: " << xml.name().toString();
  19. _result.setStyle(toCssStyle(xml.name().toString()), xml.readElementText());
  20. }
  21.  
  22. css.add(_result);
  23.  
  24. xml.readNext();
  25. continue;
  26. }
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 

This function was written to parese parts of XML file like:
Qt Code:
  1. <visited>
  2. <link name="bink1_visited">
  3. <FontColor>red</FontColor>
  4. <FontColor2>green</FontColor2>
  5. </link>
  6. </visited>
To copy to clipboard, switch view to plain text mode 
When I use this function for example
Qt Code:
  1. readStyles(_xml, "visited", "link", CssAnchorVisited);
To copy to clipboard, switch view to plain text mode 
the loop
Qt Code:
  1. while (!(xml.name() == id && xml.tokenType() == QXmlStreamReader::EndElement))
To copy to clipboard, switch view to plain text mode 
is working indefinitely. Why? What do I do wrong?

And the second thing, I cannot read arguments (in my code "name") in line:
Qt Code:
  1. _result.setName(xml.attributes().value("name").toString());
To copy to clipboard, switch view to plain text mode 

ps. Sory for my English :-) I'm still learning