title: Replace child in XML
body: <pre><code>&lt;?php
  $files = glob('users/*.xml');
  foreach($files as $file) {
      $xml = new SimpleXMLElement($file, 0, true);
      echo '
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="radio" name="browser" onclick="check(this.value)" value="'. basename($file) .'"&gt;&lt;/td&gt;
              &lt;td class="alternate-row1"&gt;'. basename($file, '.xml') .'&lt;/td&gt;
              &lt;td&gt;&lt;span id="itm1" onclick="exchange(this.id)"&gt;'. $xml-&gt;name .'&lt;/span&gt;&lt;input id="itm1b" class="replace" type="text" name="newname"&gt;&lt;/td&gt;
              &lt;td class="alternate-row1"&gt;'. $xml-&gt;lastname .'&lt;/td&gt;
              &lt;td&gt;'. $xml-&gt;email .'&lt;/td&gt;
              &lt;td class="alternate-row1"&gt;'. $xml-&gt;level .'&lt;/td&gt;
              &lt;td&gt;'. $xml-&gt;birthday .'&lt;/td&gt;
              &lt;td class="alternate-row1"&gt;'. $xml-&gt;gender .'&lt;/td&gt;
              &lt;td&gt;'. $xml-&gt;age .'&lt;/td&gt;
              &lt;td class="alternate-row1"&gt;'. $xml-&gt;country .'&lt;/td&gt;
          &lt;/tr&gt;';
  }
  session_start();
  if (isset($_POST['save'])){
      $member = $_POST['newname'];
      $dom = new DOMDocument();
      $dom-&gt;load('users/' . basename($file) . '.xml');
      $editname = $dom-&gt;getElementsByTagName('name');
      $newname = $dom-&gt;createTextNode($member);
      foreach ($editname as $edit) {
         $edit-&gt;parentNode-&gt;replaceChild($newname, $edit);
      }
      $dom-&gt;save('users/' . basename($file) . '.xml');
  }
  ?&gt;
  </code></pre>
  
  <p>So I've made this code, as you can see it got DOM and Simple XML element.
  I trying to replace child using <code>$_POST</code> throw input command, the input box is in the echo part above and I using js replacement code, it replace text to input text by onclick command (not really important for my question, it just for explaining).
  Anyway I got little stuck with the code since it not working, I got set the <code>$_POST</code>, I try use some guides I found in Stack Overflow but it didn't work since it not matches my code.</p>
  
  <p>Do you have any answer to me?</p>
  
  <p>Thank you for the assistance, Y. D.</p>