aky je dobry xml parser

zdravim,
chcem sa spytat ci uz niekto z vas parsoval/pouzival xml na ukladanie roznych dat. ide o to, ze mam uz vlastny xml parser, ale ten mi nezachovava "strukturu" xmlka - t.j. viem si vytiahnut data/atributy ale neviem zistit, presnu stromovu strukturu.
ak niekto mate nieco podobne urobene alebo poznate link na jednoduchy xml parser, budem velmi vdacny.
Ja jsem si upravil priklad z dokumentace PHP XML Parser Functions. Nacita to vlastne strukturu celeho dokumentu jako DOM XML a taky je to odpovidajicim zpusobem pomaly, ale na kratsi veci to jde v pohode.

define('LXML_TAG',0);
define('LXML_TEXT',1);
define('LXML_PI',2);
define('LXML_OTHER',3);
$file = "http://localhost/psc/psc.php?vyraz=".urlencode('Letohrad');
class xmlelement{
var $type;
}

class xml{
var $parser;
var $hloubka=0;
var $vnoreni=array();

function xml() {
$this->parser = xml_parser_create();
xml_set_object($this->parser, &$this);
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($this->parser, "tag_open", "tag_close");
xml_set_character_data_handler($this->parser, "cdata");
xml_set_default_handler($this->parser, "h_other");
xml_set_processing_instruction_handler($this->parser, "h_pi");
}

function parse($data) {
$hloubka=0;
$this->vnoreni=array();
$this->vnoreni[$this->hloubka]=new xmlelement;
xml_parse($this->parser, $data,true);
return $this->vnoreni[0];
}

function tag_open($parser, $tag, $attributes) {
$ne=new xmlelement;
$this->vnoreni[$this->hloubka]->children[]=&$ne;
$ne->name=$tag;
$ne->attribs=&$attributes;
$ne->type=LXML_TAG;
$ne->children=array();
$this->vnoreni[++$this->hloubka]=&$ne;
}

function cdata($parser, $cdata) {
$ocdata=trim($cdata);
if ($ocdata){
$ne=new xmlelement;
$this->vnoreni[$this->hloubka]->children[]=&$ne;
$ne->content=$ocdata;
$ne->type=LXML_TEXT;
}
}

function tag_close($parser, $tag){
$this->hloubka--;
}

function h_pi($parser, $target, $cdata){
$ne=new xmlelement;
$this->vnoreni[$this->hloubka]->children[]=&$ne;
$ne->target=$target;
$ne->content=$cdata;
$ne->type=LXML_PI;
}

function h_other($parser, $cdata){
if (substr($cdata,0,5)=='<?xml'){
preg_match_all('/\s*([^=\s]*)\s*=\s*"([^"]*)"/', $cdata, $pole, PREG_SET_ORDER);
foreach ($pole as $val) {
if ($val[1]=="encoding") $this->vnoreni[0]->encoding=$val[2];
elseif ($val[1]=="version") $this->vnoreni[0]->version=$val[2];
}
} elseif (trim($cdata)){
if ($cdata{0}=='<'){
$ne=new xmlelement;
$ne->type=LXML_OTHER;
$ne->parts=array();
$this->vnoreni[$this->hloubka]->children[]=&$ne;
$this->vnoreni[++$this->hloubka]=&$ne;
$this->vnoreni[$this->hloubka]->parts[]=$cdata;
}
elseif ($cdata{0}=='>'){
$this->vnoreni[$this->hloubka]->parts[]=$cdata;
$this->hloubka--;
} else {
$this->vnoreni[$this->hloubka]->parts[]=$cdata;
}
}
}
}

$xml_parser = new xml();
print_r($xml_parser->parse(file_get_contents($file)));
Nekolik obdobnych skriptu (mozna i lepsich] je i v online dokumentaci XML Parser Functions na php.net.
super. vyzera,ze to zachovava strukturu. vyskusam...
dik.