$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); }