Return to Snippet

Revision: 59200
at August 23, 2012 19:44 by tucq88


Initial Code
//Save data to an xml
App::import('Helper', 'Xml');
App::import('Core','File');
$xml = new XmlHelper();
$file = $xml->header();
$file .= $xml->serialize($config, array('whitespace' => true));
			
$xmlFile = new File(path_to_file);
$xmlFile->write($file, 'w');
$xmlFile->close();

//Read data from an XML
if (file_exists(path_to_file)) {
   App::import('Helper', 'Xml');
   $parsed_xml = new XML(path_to_file);
   $data = $parsed_xml->toArray();
   $this->data['Email'] = $data['StdClass'];
}

Initial URL


Initial Description
A simple code to read/write an XML file by using Cakephp 1.3.

Initial Title
Read/Write data to an XML file

Initial Tags
php, xml

Initial Language
PHP