All pastes #108269 Raw Edit

Stuff

public php v1 · immutable
#108269 ·published 2006-07-31 11:53 UTC
rendered paste body
		function startElement( &$parser, $tag, $attributes )		{			$this->data = '';			$this->last_opened_tag = $tag;			if ( is_array( $this->parent ) and array_key_exists( $tag, $this->parent ) )			{				if ( is_array( $this->parent[$tag] ) and array_key_exists( 0, $this->parent[$tag] ) )				{					$key = $this->count_numeric_items( $this->parent[$tag] );				}				else				{					if ( array_key_exists( "$tag attr" , $this->parent ) )					{						$arr = array( '0 attr'=>&$this->parent["$tag attr"], &$this->parent[$tag] );						unset($this->parent["$tag attr"]);					}					else						$arr = array( &$this->parent[$tag] );					$this->parent[$tag] = &$arr;					$key = 1;				}				$this->parent = &$this->parent[$tag];			}			else				$key = $tag;			if ( $attributes ) $this->parent["$key attr"] = $attributes;			$this->parent  = &$this->parent[$key];			$this->stack[] = &$this->parent;		}		function characterData( &$parser, $data )		{			if ( $this->last_opened_tag != NULL )				$this->data .= $data;		}		function endElement( &$parser, $tag )		{			if ( $this->last_opened_tag == $tag )			{				$this->parent = $this->data;				$this->last_opened_tag = NULL;			}			array_pop($this->stack);			if ( $this->stack ) $this->parent = &$this->stack[count($this->stack)-1];		}