title: Updating XML node with PHP
body: <p>I've an XML file test.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;info&gt;
    &lt;user&gt;
      &lt;name&gt;
        &lt;firstname&gt;FirstName&lt;/firstname&gt;
        &lt;lastname&gt;Last Name&lt;/lastname&gt;
        &lt;nameCoordinate&gt;
          &lt;xName&gt;125&lt;/xName&gt;
          &lt;yName&gt;20&lt;/yName&gt;
        &lt;/nameCoordinate&gt;
      &lt;/name&gt;
    &lt;/user&gt;
  &lt;/info&gt;
  </code></pre>
  
  <p>I'm trying to update the node xName &amp; yName using PHP on a form submission. So, I've loaded the file using simplexml_load_file(). The PHP form action code is below</p>
  
  <pre><code>&lt;?php 
      $xPostName = $_POST['xName'];
      $yPostName = $_POST['yName'];
  
      //load xml file to edit
          $xml = simplexml_load_file('test.xml');
  
      $xml-&gt;info-&gt;user-&gt;name-&gt;nameCoordinate-&gt;xName = $xPostName;
      $xml-&gt;info-&gt;user-&gt;name-&gt;nameCoordinate-&gt;yName = $yPostName;
      echo "done";
  ?&gt;
  </code></pre>
  
  <p>I want to update the node values but the above code seems to be incorrect. Can anyone help me rectify it??</p>
  
  <p>UPDATE:
  My question is somewhat similar to this <a href="https://stackoverflow.com/questions/171539/updating-a-xml-file-using-php">Updating a XML file using PHP</a> but here, I'm loading the XML from an external file and also I'm updating an element, not an attribute. That's where my confusion lies.</p>