Quote Originally Posted by kabanek View Post
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?
What is this while() loop supposed to do?

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 
Attributes are reported in StartElement and not EndElement.

I'm not sure what you want to achieve but I think you are overcomplicating things, try this:
Qt Code:
  1. JList<JCss> JTemplate::readStyles(QXmlStreamReader &xml, QString parentId, QString id )
  2. {
  3. JList<JCss> css;
  4. Q_ASSERT(xml.name() == parentId);
  5. while(xml.readNextStartElement() {
  6. if(xml.name() == parentId) {
  7. while(xml.readNextStartElement()){
  8. if(xml.name() == id){
  9. JCss _result;
  10. _result.setName(xml.attributes().value("name").toString());
  11. qDebug() << "Styl:" << xml.name();
  12. _result.setStyle(...); // I don't think readElementText() will work here without using a CDATA section
  13. css.add(_result);
  14. } else xml.skipCurrentElement(); // skip unknown tags
  15. }
  16. xml.skipCurrentElement(); // read until end of parentId tag
  17. } else xml.skipCurrentElement(); // skip unknown tags
  18. }
  19. return css;
  20. }
To copy to clipboard, switch view to plain text mode