<?
// +----------------------------------------------------------------------+
// | xml2db / Example |
// | Creating SQL Queries from a xml file |
// | Requirements: PHP5 with SimpleXML Support |
// | This file explains how to use and call the class |
// +----------------------------------------------------------------------+
// | Author: Nico Puhlmann <nico@puhlmann.com> |
// +----------------------------------------------------------------------+
// $Id: example.php,v 1.0 2oo5/o4/29 18:11:23 npuhlmann Exp $
include( dirname(__FILE__) . "/class.xml2db.php");
// Call the class with the root element of the xml data
$xml2db = new xml2db("product");
// Set (path to) XML file
$xml2db->setXMLFile("test.xml");
// The table name for the insert queries
$xml2db->setTable("cellphones");
// configuration array
$xml2db->setData(array
(
// xml node type db field attr name
array( "", "attr", "id", "id" ),
array( "brand", "node", "manufacturer" ),
array( "brand", "attr", "type", "type" ),
array( "model", "node", "name" ),
array( "price", "node", "price" ),
));
// Just a test printout - you can perfom the queries here
echo "<pre>";
print_r($xml2db->getQueries());
echo "</pre>";
?>
|