title: How to access and overwrite XML data using SimpleXML?
body: <p>I have a XML file : photo.xml which looks like this.</p>
  
  <pre><code>       &lt;?xml version="1.0" ?&gt; 
         - &lt;users&gt;
             - &lt;uploader ID="11"&gt;
               &lt;Name&gt;moz&lt;/Name&gt; 
               &lt;Photos_Uploaded&gt;2&lt;/Photos_Uploaded&gt; 
             &lt;/uploader&gt;
  
           &lt;/users&gt;
  </code></pre>
  
  <p>So each time the user moz uploads a new photo, the XML file should increment photos_uploaded by 1. I have already done this with PHP.</p>
  
  <p>What i am asking is how do i use SimpleXML to access the photo.xml and modify the data to reflect the change and save it? </p>
  
  <p>regards</p>
  
  <p>Edit: </p>
  
  <p>I tried this but it did not work. </p>
  
  <pre><code>    $xml_Doc = new DOMDocument();
      $xml_Doc-&gt;load('photo.xml');
  
  
          $statistics="SELECT firstname AS 'user', count( * ) AS 'num',member_id AS ID
          FROM members
          JOIN member_photo
          USING ( member_id )
          GROUP BY firstname ";
          $result= mysql_query($statistics);
  
  
      while($row=mysql_fetch_assoc($result)) {
  
      $uploader=$xml-&gt;addChild('uploader');
      $uploader-&gt;addAttribute('ID',$row['ID']);
      $uploader-&gt;addChild('Name', $row['user']);
      $uploader-&gt;addChild('Photos_Uploaded', $row['num']);
      $xml-&gt;asXML('');
  
      }
  </code></pre>