Hi

How to update a textnode data in xml through QDomElement.
I have following code

Qt Code:
  1. static QDomDocument doc;
  2. static QDomElement root,root1;
  3. QDomElement statement, action_node, condition_node;
  4. QDomText id_text;
  5. root = doc.createElement("root");
  6. QFile *file = new QFile("E:/new.txt");
  7. if(!file->exists())
  8. {
  9. file->open(QIODevice::WriteOnly);
  10. QDomElement id = doc.createElement("id");
  11. id_text = doc.createTextNode("0");
  12. root.appendChild(id);
  13. id.appendChild(id_text);
  14. doc.appendChild(root);
  15. }
  16. else
  17. {
  18. file->open(QFile::ReadWrite);
  19. doc.setContent(file);
  20. root1 = doc.documentElement();
  21. QDomElement node = root1.firstChildElement("id");
  22. QString string_data = node.text();
  23. int a = string_data.toInt();
  24. qDebug()<<string_data;
  25. string_data.clear();
  26. id_text = doc.createTextNode("Qt"); // Here i want to write Qt but it is getting write 0Qt on the textnode.
  27. node.appendChild(id_text);
  28. statement = doc.createElement("statement");
  29. condition_node = doc.createElement("condition");
  30. action_node = doc.createElement("action");
  31. QDomText condition_text = doc.createTextNode(condition_text_edit->toPlainText());
  32. QDomText action_text = doc.createTextNode(action_text_edit->toPlainText());
  33. statement.setAttribute("id", i);
  34. statement.appendChild(condition_node);
  35. statement.appendChild(action_node);
  36. condition_node.appendChild(condition_text);
  37. action_node.appendChild(action_text);
  38. root1.appendChild(statement);
  39.  
  40. // QString str = statement.attribute("id");
  41. // qDebug()<<str.toInt();
  42. file->seek(0);
  43.  
  44. }
  45. QTextStream out(file);
  46. doc.save(out, Indent);
To copy to clipboard, switch view to plain text mode 
So i want to update the textnode value while it is getting append in previous value.
Please anyone help me.
Waiting for response.