Zend Framework

iterating over a Zend_Config

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.7.7, 1.7.8, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9.0, 1.9.1, 1.9.2
  • Fix Version/s: None
  • Component/s: Zend_Config
  • Labels:
    None

Description

There are two xml-files.

config1.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
    <files>
        <file id="index" location="index.html" />
        <file id="main_css" location="css/main.css" />
        <file id="main_js" location="js/main.js" />
    </files>
</root>

and

config2.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
    <files>
        <file id="index" location="index.html" />
    </files>
</root>

and the sample code:

index.php
<?php
    require_once 'Zend/Config.php';
    require_once 'Zend/Config/Xml.php';
    
    $config = new Zend_config_xml('/path/to/config.xml');
    foreach ($config->files->file as $value)
        echo 'id: '.$value->id.'<br />location: '.
            htmlspecialchars($value->location).'<hr />';
?>

If the /path/to/config.xml to substitute config1.xml, then everything works correctly. But if you substitute config2.xml error

Notice: Trying to get property of non-object in D:\www\index.php on line 7

How can I iterate all items file, if their number is not known in advance (one or more than one)?

Issue Links

Activity

Hide
Patrick van Dissel added a comment -

This issue is related to ZF-6109, but I create this clone issue because the original is set only for ZF version 1.7.7, but ZF version 1.9.2 still has the issue

Show
Patrick van Dissel added a comment - This issue is related to ZF-6109, but I create this clone issue because the original is set only for ZF version 1.7.7, but ZF version 1.9.2 still has the issue
Hide
Patrick van Dissel added a comment -

See related issue for more comments on this issue

Show
Patrick van Dissel added a comment - See related issue for more comments on this issue
Hide
Rob Allen added a comment -

How can I iterate all items file, if their number is not known in advance (one or more than one)?

The more important question is how do we solve this without breaking backwards compatibility?

Show
Rob Allen added a comment -
How can I iterate all items file, if their number is not known in advance (one or more than one)?
The more important question is how do we solve this without breaking backwards compatibility?
Hide
Rob Allen added a comment -

Duplicate of ZF-6109

Show
Rob Allen added a comment - Duplicate of ZF-6109

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: