Page 1 of 1

XML parsing

Posted: Thu Oct 12, 2006 2:41 pm
by impulse()
Is this when you extract data from a XML document for use within PHP/MySQL, or any other language that can handle XML?

If so, how easily is this done? Is it a big topic for me to cover?

Posted: Thu Oct 12, 2006 5:17 pm
by Luke
check out SimpleXML... makes parsing XML pretty trivial.

Posted: Thu Oct 12, 2006 5:22 pm
by impulse()
I've been reading a good tutorial on it for the past couple of hours. It's really interesting stuff. It's like nothing I've done it PHP before because I'm actually creating functions to use as an argument in other functions.

Posted: Thu Oct 12, 2006 5:29 pm
by Luke
if you're having fun with functions, here's what you have to look forward to in OOP...
This is my index page for my File Manager I'm building...

Code: Select all

<?php
error_reporting(E_ALL);
date_default_timezone_set('America/Los_Angeles');
set_include_path(get_include_path() . PATH_SEPARATOR . "C:\\wamp\\www\\FileManager\\library");

// Prepare autoloader (Special Thanks to Chris Corbyn for this autoloader!)
require_once 'library/Autoloader.php';
require_once 'library/PearLocator.php';
Autoloader::attach(new PearLocator('library'), 'library');
Autoloader::attach(new PearLocator('application/model'), 'model');
Autoloader::attach(new PearLocator('C:\wamp\php\PEAR'), 'PEAR');

// Load config data
$Config = new Zend_Config(Zend_Config_Ini::load('application/config/config.ini', 'general'));
Zend::register('config', $Config);

// Prepare view
$View = new Zend_View;
Zend::register('view', $View);

// Prepare Mysql database
$Mysql = Mysql::getInstance(
	$Config->mysql->host,
	$Config->mysql->user,
	$Config->mysql->pass,
	$Config->mysql->db	
);
//if(!$Mysql->isConnected()) echo "Not connected!";
Mysql_Model::$mysql = $Mysql;
Zend::register("mysql", $Mysql);

// Prepare rewrite routes
$route = new Zend_Controller_RewriteRouter();
$route->setRewriteBase("/FileManager/");

$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($route);
$controller->run('application/controller');
?>

Posted: Thu Oct 12, 2006 5:36 pm
by impulse()
That looks nasty.

When using

Code: Select all

xml_set_element_handler
Does it bounce between the start tag function and the end tag function when processing. By that I mean will it run the start tag code, then run the data handling code, then run the end tag code for each XML entry. Then move to the next tag in the XML file?