PHP-How to choose XML section based on an attribute?
- by Vincent
All,
I have a config xml file in the following format:
<?xml version="1.0"?>
<configdata>
<development>
<siteTitle>You are doing Development</siteTitle>
</development>
<test extends="development">
<siteTitle>You are doing Testing</siteTitle>
</test>
<production extends="development">
<siteTitle>You are in Production</siteTitle>
</production>
</configdata>
To read this config file to apply environment settings, currently I am using, the following code in index.php file:
$appEnvironment = "production";
$config = new Zend_Config_Xml('/config/settings.xml', $appEnvironment );
To deploy this code on multiple environments, as user has to change index.php file. Instead of doing that, is it possible to maintain an attribute in the xml file, "say active=true". Based on which the Zend_Config_Xml will know which section of the xml file settings to read?
Thanks