note 51240 deleted from function.xml-parse-into-struct by betz

From: Date: Fri, 25 Mar 2005 11:47:28 +0000
Subject: note 51240 deleted from function.xml-parse-into-struct by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86950@lists.php.net to get a copy of this message
Note Submitter: ---- [...continue] ............... // ------------------------------------------------ function _xml_runner( &$content ){ $content = NULL; $level_tags = array(); while ( $position = next($this->_structure)){ // [1] ................................................... // if we found "open" tag, so make a recursive tag reading if ( $position['type'] == 'open' ){ $content[$position['tag']] = NULL; $this->_xml_runner( $value ); // if it is a second tag in this conteiner, we need to reorganize // string to array and add second similar tag if (isset($level_tags[$position['tag']]) && $level_tags[$position['tag']] == 1 ){ $intermediate = $content[$position['tag']]; $content[$position['tag']] = array(); $content[$position['tag']][] = $intermediate; $content[$position['tag']][] = $value; $level_tags[$position['tag']]++; } // if more than two tags in container - then reorganiztion was made, jaust add value elseif ( isset($level_tags[$position['tag']]) && $level_tags[$position['tag']] > 1 ){ $content[$position['tag']][] = $value; $level_tags[$position['tag']]++; } // if tag in container - lets just register it, so we can search duplicates else { $content[$position['tag']] = $value; $level_tags[$position['tag']] = 1; } $this->_xml_exit(); } // [2] ................................................... // else - if it is closed, just read its content elseif ( $position['type'] == 'complete' ){ // ... add [VALUE] .............. if (isset($position['value'])) { // if it is a second tag in this conteiner, we need to reorganize // string to array and add second similar tag if (isset($level_tags[$position['tag']]) && $level_tags[$position['tag']] == 1 ){ $intermediate = $content[$position['tag']]; $content[$position['tag']] = array(); $content[$position['tag']][] = $intermediate; $content[$position['tag']][] = $position['value']; $level_tags[$position['tag']]++; } // if more than two tags in container - then reorganiztion was made, jaust add value elseif ( isset($level_tags[$position['tag']]) && $level_tags[$position['tag']] > 1 ){ $content[$position['tag']][] = $position['value']; $level_tags[$position['tag']]++; } // if tag in container - lets just register it, so we can search duplicates else { $content[$position['tag']] = $position['value']; $level_tags[$position['tag']] = 1; } } // ... add [ATRRIBUTE] ................ elseif (isset($position['attributes'])) $content[$position['tag']] = $position['attributes']; } } return true; } // ------------------------------------------------ function _xml_exit() { // "cdata" or "close" expected // ( just to go to the end of conteiner ) while ( $position = next($this->_structure) ) { if ($position['type'] == "close") break; } return true; } // ------------------------------------------------- }// end of class

« previous php.notes (#86950) next »