_xml_depth($vals, $i); return $array; } private final function _xml_depth($vals, &$i) { $children = array(); if ( isset($vals[$i]['value']) ) { array_push($children, $vals[$i]['value']); } while ( ++$i < count($vals) ) { switch ($vals[$i]['type']) { case 'open': if ( isset ( $vals[$i]['tag'] ) ) { $tagname = $vals[$i]['tag']; } else { $tagname = ''; } if ( isset ( $children[$tagname] ) ) { $size = sizeof($children[$tagname]); } else { $size = 0; } if ( isset ( $vals[$i]['attributes'] ) ) { $children[$tagname][$size]['@'] = $vals[$i]["attributes"]; } $children[$tagname][$size]['#'] = $this->_xml_depth($vals, $i); // end case 'open' break; case 'cdata': array_push($children, $vals[$i]['value']); // end case 'cdata' break; case 'complete': $tagname = $vals[$i]['tag']; if( isset ($children[$tagname]) ) { $size = sizeof($children[$tagname]); } else { $size = 0; } if( isset ( $vals[$i]['value'] ) ) { $children[$tagname][$size]["#"] = $vals[$i]['value']; } else { $children[$tagname][$size]["#"] = array(); } if ( isset ($vals[$i]['attributes']) ) { $children[$tagname][$size]['@'] = $vals[$i]['attributes']; } // end case 'complete' break; case 'close': return $children; // end case 'close' break; } } return $children; } } ?>