title: php and simpleXml - how to change node contents
body: <p>I'm trying to change the contents of a node in an XML file using simpleXML. I know that the variable for the new node-contents contains the right stuff, but for some reason the file isn't changed when it is saved. I'm probably missing something basic, because I'm new to simpleXML. Here is the whole php script:</p>
  
  <pre><code>&lt;?php 
      $doc=$_REQUEST["book"];
      $div1=$_REQUEST["div1"];
      $div2=$_REQUEST["div2"];
      if ($div1=="") $div1=$_REQUEST["chapter"];
      if ($div2=="") $div2=$_REQUEST["verse"];
      $div3=$_REQUEST["div3"];
      $textresponse=$_REQUEST["xmltext"];
      $strippedresponse = "&lt;?xml version='1.0'?&gt;" . stripslashes($textresponse);
      echo("Saved changes to " . $doc . " " . $div1 . "." . $div2 ."&lt;br /&gt;");    
      $fileName="/home/ocp/public_html/sites/default/docs/drafts/".$doc.".xml";
      $xmlDoc = simplexml_load_file($fileName);
      $backupFileName="/home/ocp/public_html/sites/default/docs/backups/".$doc." ".date("Y-m-d H.i.s").".xml";
      file_put_contents($backupFileName, $xmlDoc-&gt;asXML());
      $backupSize = filesize($backupFileName);
      echo("Backup {$backupFileName} created:".$backupSize." bytes&lt;br /&gt;");
      if ($doc) {
          if ($div1) {
              if ($div2) {
                  $newVerse = simplexml_load_string($strippedresponse);
          $oldVerse = $xmlDoc-&gt;xpath("//div[@number='".$div1."']/div[@number='".$div2."']"); 
          $oldVerse = $newVerse;
  
                  $newDoc = $xmlDoc-&gt;asXml();
              file_put_contents($fileName, $newDoc);
              $newSize = filesize($fileName);
                  echo("New file is ".$newSize." bytes &lt;br /&gt;");
              }
          }
      }
  ?&gt;
  </code></pre>