note 25782 added to function.xml-parse-into-struct
| From: | ambi at rack1 dot php dot net | Date: | Sat, 05 Oct 2002 20:59:27 +0000 |
| Subject: | note 25782 added to function.xml-parse-into-struct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37707@lists.php.net to get a copy of this message | ||
Sorry.. unreachable and unneeded code in my posting above :-)
Here is the fixed version:
function xml_condense_tree($tree) {
if ($tree["children"]) {
unset($nodecounters);
foreach ($tree['children'] as $index => $node) {
if (!isset($nodecounters[$node['tag']]))
$nodecounters[$node['tag']]=1;
else $nodecounters[$node['tag']]++;
}
foreach ($tree['children'] as $index => $node) {
if (isset($node['children'])) {
$tree['children'][$index] = xml_condense_tree($node);
} elseif (isset($node['value']) and !$node['attributes'] and
$nodecounters[$node['tag']]==1) {
$tree['values'][$node['tag']] = $node['value'];
unset($tree['children'][$index]);
}
}
}
if (!$tree['children']) unset($tree['children']);
return $tree;
}
--
http://www.php.net/manual/en/function.xml-parse-into-struct.php
http://master.php.net/manage/user-notes.php?action=edit+25782
http://master.php.net/manage/user-notes.php?action=delete+25782
http://master.php.net/manage/user-notes.php?action=reject+25782