Hello,
I try to import the contents of an XML file into MySQL database.
Details of the XML file format and the table in the database can be found here:
http://stackoverflow.com/questions/11560946/cakephp-import-xml-data-to-database
I have tried to develop a found piece of code, but without success.
Here it is:
Importer model
<?php
class Importer extends AppModel {
var $name = 'Importer';
var $useTable = false;
function import_offers(){
App::import('Xml');
$file = "../webroot/files/file.xml";
$parsed_xml =& new XML($file);
$parsed_xml = Set::reverse($parsed_xml);
debug($parsed_xml);
}
}
Importer Controller
<?php
class ImporterController extends AppController {
var $name = 'Importer';
var $uses = array('Offer');
function import_offers($parsed_xml) {
$this->loadModel('Importer');
$offers = $this->Importer->find('all');
$this->set('offers', $offers);
}
}
Please help to add a piece of code (loops), which will import specific fields from xml to table Offers
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Friday, July 20, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment