Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #3051 trying to getItem('directive') always return the last one
Submitted: 2004-12-29 13:51 UTC
From: divoxx Assigned:
Status: Bogus Package: Config
PHP Version: 5.0.2 OS: Linux Fedora Core 3
Roadmaps: (Not assigned)    
Subscription  


 [2004-12-29 13:51 UTC] divoxx
Description: ------------ When trying to get a Directive Container in a xml config file getItem() method always return the last diretive with the same name. Reproduce code: --------------- file.xml <root> <item name='item1'/> <item name='item2'/> </root> file.php <? require_once 'Config.php'; $config = new Config(); $root =& $config->parseConfig('teste.xml', 'xml'); $root =& $root->getChild(0); for ($i=0; $i<$root->countChildren('directive', 'item'); $i++) { $item = $root->getItem('directive', 'item', null, $i); print $item->getAttribute('name')."<br/>"; } ?> Expected result: ---------------- item1 item2 Actual result: -------------- item2 item2

Comments

 [2004-12-29 20:30 UTC] ryansking at mac dot com
Thank you for taking the time to write to us, but this is not a bug. You just need to add a parameter to your getItem method call: $item = $root->getItem('directive', 'item', null, null, $i);
 [2004-12-30 11:37 UTC] divoxx
Oh. My bad.