Hi, everyone!

I read the xml-file:

Qt Code:
  1. <Matrix>
  2. <Description>
  3. <rows>3</rows>
  4. <columns>4</columns>
  5. </Description>
  6. <row1>
  7. <cell>23.7</cell>
  8. <cell>2.7</cell>
  9. <cell>3.7</cell>
  10. <cell>23.9</cell>
  11. </row1>
  12. <row2>
  13. <cell>13.0</cell>
  14. <cell>2.7</cell>
  15. <cell>3.7</cell>
  16. <cell>2</cell>
  17. </row2>
  18. <row3>
  19. <cell>2.5</cell>
  20. <cell>2.7</cell>
  21. <cell>3.7</cell>
  22. <cell>23.9</cell>
  23. </row3>
  24. </Matrix>
To copy to clipboard, switch view to plain text mode 

I want to write to the console these names of tags 'row1' and 'row2':

Qt Code:
  1. qDebug() << rowElement1.tagName();
  2. qDebug() << rowElement2.tagName();
To copy to clipboard, switch view to plain text mode 

I expect to see:
"row1"
"row2"
But I see:
"row1"
"row1"
Qt Code:
  1. #include <QApplication>
  2.  
  3. #include <QFile>
  4. #include <QTextStream>
  5.  
  6. #include <QDomDocument>
  7. #include <QDomElement>
  8. #include <QDomText>
  9.  
  10. #include <QMessageBox>
  11.  
  12. #include <QDebug>
  13. #include <QObject>
  14.  
  15. int main(int argc, char **argv)
  16. {
  17. QApplication app(argc, argv);
  18.  
  19. QFile file( "matrix.xml" );
  20. if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
  21. {
  22. QMessageBox::critical(NULL, QObject::tr("Error"), QObject::tr("Failed to open file for reading"));
  23. return 0;
  24. }
  25.  
  26. QDomDocument document;
  27. if( !document.setContent( &file ) )
  28. {
  29. QMessageBox::critical(NULL, QObject::tr("Error"), QObject::tr("Failed to parse the file into a DOM tree"));
  30. file.close();
  31. return 0;
  32. }
  33.  
  34. file.close();
  35.  
  36. QDomElement matrixElement = document.documentElement();
  37.  
  38. QDomNode descriptionNode = matrixElement.firstChild();
  39.  
  40. QDomElement rowElement1 = descriptionNode.nextSiblingElement();
  41. qDebug() << rowElement1.tagName();
  42.  
  43. QDomElement rowElement2 = descriptionNode.nextSiblingElement();
  44. qDebug() << rowElement2.tagName();
  45.  
  46. app.exec();
  47. }
To copy to clipboard, switch view to plain text mode 

Thanks!

Ivan