title: Edit and save simple XML by php
body: <p>I found this script and it works, but I would like to edit all the children, not just the first one.
  It's possible?</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;?php
  $xml = new DOMDocument('1.0', 'utf-8');
  $xml-&gt;formatOutput = true;
  $xml-&gt;preserveWhiteSpace = false;
  $xml-&gt;load('file.xml');
  
  //Get item Element
  $element = $xml-&gt;getElementsByTagName('global')-&gt;item(0);
  
  //Load child elements
  $name = $element-&gt;getElementsByTagName('data')-&gt;item(0);
  
  
  //Replace old elements with new
  $element-&gt;replaceChild($name, $name);
  
  ?&gt;
  
  &lt;?php
  if (isset($_POST['submit']))
  {
  $name-&gt;nodeValue = $_POST['namanya'];
  htmlentities($xml-&gt;save('index_messages_en.xml'));
  
  }
  
  ?&gt;
  
  &lt;form method="POST" action=''&gt;
  &lt;p&gt;&lt;?php echo $name-&gt;nodeValue  ?&gt;&lt;/p&gt;&lt;input type="text-name" value="&lt;?php echo $name-&gt;nodeValue  ?&gt;" name="namanya" /&gt;
  &lt;input name="submit" type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The format of my xml documents is : </p>
  
  <pre><code>&lt;global&gt;
  
    &lt;data name="title"&gt;&lt;![CDATA[data1]]&gt;&lt;/data&gt;
    &lt;data name="author_name"&gt;&lt;![CDATA[data2]]&gt;&lt;/data&gt;
  
  &lt;global&gt;
  </code></pre>
  
  <p>I would like the file to become like that</p>
  
  <p></p>
  
  <pre><code>  &lt;data name="title"&gt;&lt;![CDATA[NEWdata1]]&gt;&lt;/data&gt;
    &lt;data name="author_name"&gt;&lt;![CDATA[NEWdata2]]&gt;&lt;/data&gt;
  
  &lt;global&gt;
  </code></pre>
  
  <p>Thanks
  Mau </p>