XML parsing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

XML parsing

Post 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?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

check out SimpleXML... makes parsing XML pretty trivial.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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');
?>
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post 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?



Post Reply