Hi all

I am reading a xml file but i am not successing in reading it. My code for reading file is

Qt Code:
  1. Xmlhandler::Xmlhandler(QTableWidget *table)
  2. {
  3. tablewidget = table;
  4. table_item = 0;
  5. }
  6.  
  7. bool Xmlhandler::startElement(const QString &, const QString &, const QString &qName,const QXmlAttributes &attributes)
  8. {
  9. if (qName == "statement"){
  10. tablewidget->insertRow(1);
  11.  
  12. if(qName == "Condition")
  13. {
  14. QString str_id = attributes.value("text");
  15. qDebug()<<str_id;
  16. table_item = new QTableWidgetItem();
  17.  
  18. }
  19. else if(qName == "action")
  20. {
  21. QString str_id = attributes.value("text");
  22. qDebug()<<str_id;
  23. table_item = new QTableWidgetItem();
  24.  
  25. }
  26. else if(qName == "text")
  27. currenttext.clear();
  28. }
  29. return true;
  30. }
  31.  
  32. bool Xmlhandler::characters(const QString &str)
  33. {
  34. currenttext += str;
  35. return true;
  36. }
  37.  
  38. bool Xmlhandler::endElement(const QString &,const QString &,const QString &qName)
  39. {
  40. if(qName == "statement"){
  41. if (qName == "Condition") {
  42. if (qName == "page") {
  43. table_item->setText(currenttext);
  44. tablewidget->setItem(0, 0, table_item);
  45. }
  46. }
  47. if (qName == "action") {
  48. if (qName == "page") {
  49. table_item->setText(currenttext);
  50. tablewidget->setItem(0, 1, table_item);
  51. }
  52. }
  53. }
  54. return true;
  55. }
  56.  
  57. bool Xmlhandler::fatalError(const QXmlParseException &exception)
  58. {
  59. QMessageBox::warning(0, QObject::tr("SAX Handler"),QObject::tr("Parse error at line %1, column "
  60. "%2:\n%3.").arg(exception.lineNumber()).arg(exception.columnNumber()).arg(exception.message()));
  61. return false;
  62. }
To copy to clipboard, switch view to plain text mode 

and my xml file is like this-

<?xml version="1.0" encoding="UTF-8"?>
<statement>
<Condition id="1">
<text></text>
</Condition>
<action id="1">
<text></text>
</action>
</statement>

<statement>
<Condition id="2">
<text>Analog Input Equals to 1 END</text>
</Condition>
<action id="2">
<text>Digital Output Equals to ON END</text>
</action>
</statement>

i am trying to read xml and display it in a table.

Please guide me , i am doing this since three days but i am not getting desired result.

Thank you.