data ); $this->data = new xml_object; $file = file_get_contents( $file ); $this->data->itemTag = $itemTag; $this->data->items = array(); $this->data->tags = explode( ",", $tags ); for ( $c = 0; $c < count( explode( "<". $this->data->itemTag, $file ) )-1; $c++ ) { foreach ( $this->data->tags as $key => $value ) { $this->data->items[$c][$value] = ""; } } $parser = xml_parser_create(); xml_set_object( $parser, $this->data ); xml_set_element_handler( $parser, array( &$this, 'startElement' ), array( &$this, 'endElement' ) ); xml_set_character_data_handler( $parser, array( &$this, 'characterData' ) ); xml_parse( $parser, $file, true ); xml_parser_free( $parser ); return $this->data; } function startElement( $parser, $tagName, $attrs ) { if ( $this->data->inside ) $this->data->curTag = strtolower( $tagName ); elseif ( strtolower( $tagName ) == $this->data->itemTag ) { if ( is_array( $attrs ) ) { foreach ( $attrs as $field => $value ) { $n = $this->data->itemNum; $f = strtolower($field); $this->data->items[$n]['ATTRS'][$f] = $value; } } $this->data->inside = true; } elseif ( is_array( $attrs ) ) { if ( $this->data->inside ) { $this->data->hasAttrs = true; foreach ( $attrs as $field => $value ) { $n = $this->data->itemNum; $t = $this->data->curTag; $f = strtolower( $field ); $this->data->items[$n][$t]['ATTRS'][$f] = $value; } } else { foreach ( $attrs as $field => $value ) { $f = strtolower( $field ); $this->data->items['ATTRS'][$f] = $value; } } } } function endElement( $parser, $tagName ) { $this->data->hasAttrs = false; if ( strtolower( $tagName ) == $this->data->itemTag ) { $this->data->inside = false; $this->data->itemNum++; } } function characterData( $parser, $data ) { if ( $this->data->inside ) { foreach ( $this->data->tags as $key => $field ) { if ( $this->data->curTag == $field ) { $n = $this->data->itemNum; if ( $this->data->hasAttrs ) { $this->data->items[$n][$field]['VALUE'] .= $data; } else { $this->data->items[$n][$field] .= $data; } } } } } function close() { } function query() { } function fetch() { } function count() { } } ?>