Thursday, October 2, 2014

Using simpleXML to edit a known node attribute

    $file = 'c:\db\server.xml';         
  try {           
   $xml = simplexml_load_file($file);
   $oStorage = $xml->xpath('/body/storage');
   $xmlElement = $oStorage[0]->attributes();
          $xmlElement['mysql_use_backup']='0';
   file_put_contents($file, $xml->asXml()); 
                               
          } catch(Exception $e){ die($e); }