Dr. Klahn
11-23-2007, 06:55 PM
So here's what I'm trying to do.
I've got an app that stores a bunch of data as xml in the database that I'm needing to pull some of it as variables in a PHP app I'm writing.
Problem: I'm not very good in PHP, so I'm basically banging my head against the wall. :wall:
Here's the code that's calling the xml. I've created an xml file with one of the entries for the moment so I can test with less variables (the database)
<?php
// include XJConf class file
include_once 'XJConf/XJConf.php';
// load facade
XJConfLoader::load('XJConfFacade');
$conf = new XJConfFacade();
// attach definitions to parser
$conf->addDefinition('defs.xml');
// parse XML
$conf->parse('retreat1.xml');
// access XML element values
echo $conf->getConfigValue('title') . " starts " . $conf->getConfigValue('start')
. " and ends " . $conf->getConfigValue('end') . ".";
?>
I'm getting the following error when I run that code:
Parse error: syntax error, unexpected T_STRING in (path)/XJConf.php on line 8
Here's the beginning of that file (line 8 is the namespace line):
<?php
/**
* Class loader for all XJConf classes.
*
* @author Frank Kleine <frank.kleine@schlund.de>
* @package XJConf
*/
namespace net::xjconf;
/**
* Class loader for all XJConf classes.
*
* The class loader takes care that all class files are only loaded once. It
* allows all classes to include the required files without knowing where they
* reside or if they have been loaded before.
*
* @package XJConf
*/
class XJConf
XJConf is a package that I downloaded to get the XML parsing. So - Questions are:
1 - Any clue what's wrong and/or how to fix?
2 - Anyone have a maybe better way to parse the xml file to get the elements loaded into the PHP prog as variables?
Thanks!
I've got an app that stores a bunch of data as xml in the database that I'm needing to pull some of it as variables in a PHP app I'm writing.
Problem: I'm not very good in PHP, so I'm basically banging my head against the wall. :wall:
Here's the code that's calling the xml. I've created an xml file with one of the entries for the moment so I can test with less variables (the database)
<?php
// include XJConf class file
include_once 'XJConf/XJConf.php';
// load facade
XJConfLoader::load('XJConfFacade');
$conf = new XJConfFacade();
// attach definitions to parser
$conf->addDefinition('defs.xml');
// parse XML
$conf->parse('retreat1.xml');
// access XML element values
echo $conf->getConfigValue('title') . " starts " . $conf->getConfigValue('start')
. " and ends " . $conf->getConfigValue('end') . ".";
?>
I'm getting the following error when I run that code:
Parse error: syntax error, unexpected T_STRING in (path)/XJConf.php on line 8
Here's the beginning of that file (line 8 is the namespace line):
<?php
/**
* Class loader for all XJConf classes.
*
* @author Frank Kleine <frank.kleine@schlund.de>
* @package XJConf
*/
namespace net::xjconf;
/**
* Class loader for all XJConf classes.
*
* The class loader takes care that all class files are only loaded once. It
* allows all classes to include the required files without knowing where they
* reside or if they have been loaded before.
*
* @package XJConf
*/
class XJConf
XJConf is a package that I downloaded to get the XML parsing. So - Questions are:
1 - Any clue what's wrong and/or how to fix?
2 - Anyone have a maybe better way to parse the xml file to get the elements loaded into the PHP prog as variables?
Thanks!