PHP-How to choose XML section based on an attribute?

Posted by Vincent on Stack Overflow See other posts from Stack Overflow or by Vincent
Published on 2010-05-13T18:50:57Z Indexed on 2010/05/13 18:54 UTC
Read the original article Hit count: 170

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about php5