title: QT - xml file -- not modifing text node content
body: <p>My xml routines :-----</p>
  
  <pre><code>int MainWindow::xmlOpenFile()
  {
      //set the name of the file
      xmlFile.setFileName(xmlFileName);
  
      // open read &amp; write mode
      if (!xmlFile.open(QIODevice::ReadWrite|QIODevice::Text))
      {
          return FAIL_TO_OPEN_FILE;
      }
  
      // Assign file to the stream
      xmlStream = new QTextStream(&amp;xmlFile);
  
      xmlDomDocument.setContent(&amp;xmlFile);
  
      return SUCCESS_TO_OPEN_FILE;
  }
  
  void MainWindow::xmlAddRoot()
  {
      // Make the root element
      xmlRoot = xmlDomDocument.createElement(ROOT_ELEMENT_DETAILS);
  
      // Add it to the document
      xmlDomDocument.appendChild(xmlRoot);
  }
  
  void MainWindow::xmlCreateNode(QDomElement &amp;NodeElement, QString Name)
  {
      // Make the node element
      NodeElement = xmlDomDocument.createElement(Name);
  
  }
  
  void MainWindow::xmlAddTextNode(QDomElement &amp;NodeElement, QString textContent)
  {
      QDomText textNode;
      textNode = xmlDomDocument.createTextNode(textContent);
      NodeElement.appendChild(textNode);
  }
  
  void MainWindow::xmlAppendNode(QDomElement &amp;xmlParent, QDomElement &amp;xmlChild)
  {
      xmlParent.appendChild(xmlChild);
  
  }
  </code></pre>
  
  <p>This my program to enter text in <code>empty</code> XML file, <code>MyXML.xml</code> :----</p>
  
  <pre><code>xmlFileName = "D:/Temp/MyXML.xml";
  
  xmlOpenFile();
  xmlAddRoot();
  
  xmlCreateNode(xmlTempNode, "hello");
  xmlAddTextNode(xmlTempNode, "hi" );
  xmlAppendNode(xmlRoot,xmlTempNode);
  
  xmlCreateNode(xmlTempNode, "hello 0");
  xmlAddTextNode(xmlTempNode, "hi 0" );
  xmlAppendNode(xmlRoot,xmlTempNode);
  
  xmlCreateNode(xmlTempNode, "hello -1");
  xmlCreateNode(xmlTempNodeChild, "hello -1 - 1");
  xmlAddTextNode(xmlTempNodeChild, "hi -1 - 1" );
  xmlAppendNode(xmlTempNode,xmlTempNodeChild);
  xmlCreateNode(xmlTempNodeChild, "hello -1 - 2");
  xmlAddTextNode(xmlTempNodeChild, "hi -1 - 2" );
  xmlAppendNode(xmlTempNode,xmlTempNodeChild);
  xmlAppendNode(xmlRoot,xmlTempNode);
  
  xmlCreateNode(xmlTempNode, "hello -2");
  xmlAddTextNode(xmlTempNode, "hi -2" );
  xmlAppendNode(xmlRoot,xmlTempNode);
  
  // Here i am replacingthe node, hello -1 
  QDomNode temp_1 = xmlRoot.firstChild().nextSibling().nextSibling();
  QDomNode temp = temp_1;
  QDomElement element = temp.toElement();
  QDomNode n = element.firstChild();
  QDomText t = n.toText();
  t.setData("Here is the new text");
  
  //Replace node "hello -1"
  xmlRoot.replaceChild(temp,temp_1);
  
  xmlCloseFile();
  </code></pre>
  
  <p>Here in above code i made 4 nodes <code>to root</code> Test Cases then i modified the 3rd child <code>xmlRoot.firstChild().nextSibling().nextSibling();</code> , but changes are not reflected in final xml file </p>
  
  <p>It created following xml file :----</p>
  
  <pre><code>&lt;Test Cases&gt;
   &lt;hello&gt;hi&lt;/hello&gt;
   &lt;hello 0&gt;hi 0&lt;/hello 0&gt;
   &lt;hello -1&gt;
    &lt;hello -1 - 1&gt;hi -1 - 1&lt;/hello -1 - 1&gt;
    &lt;hello -1 - 2&gt;hi -1 - 2&lt;/hello -1 - 2&gt;
   &lt;/hello -1&gt;
   &lt;hello -2&gt;hi -2&lt;/hello -2&gt;
  &lt;/Test Cases&gt;
  </code></pre>
  
  <p>but i want to replace <code>"hello -1"</code> node with  :---</p>
  
  <pre><code> &lt;hello -1&gt;
    &lt;hello -1 - 1&gt;Here is the new text&lt;/hello -1 - 1&gt;
    &lt;hello -1 - 2&gt;hi -1 - 2&lt;/hello -1 - 2&gt;
   &lt;/hello -1&gt;
  </code></pre>
  
  <p>Why replace child is not working <code>?</code></p>