cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

Read/Write An XML File Using CakePHP 1.3

Here’s a snippet that is sure to be quite useful for PHP programmers and web developers who often work with XML files. It’s a code to read/write an XML file by using CakePHP. Some of you might find a few lines a bit familiar, which is because parts of it are borrowed from the concept of parsing XML.


//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'];
}     

Related Posts

Adding Instagram Badges to Your WordPress Profile

How to Create a Custom WordPress Registration Form with Flat UI

How to Create A Basic Hipster-Style Layout

How to Style Nav Links Using Floats With HTML5 and CSS3

2 Comments

  1. Jleagle

    09.10.2012

    1.3 is pretty old now.

  2. dogmatic69

    09.11.2012

    When using Cake 1.3 and SimpleXml is available on your server its recommended to use that instead.

    The Xml classes are know to be quite buggy and there is a bit of a performance gain in using SimpleXml

    Since 2.x Cake wraps SimpleXml and DomDocument as its no longer targeted at php4