here is something that i found... thrown together from lots of different people it looks like... just parses the document into an associative array... so you can user normal php logic on the display
may or may not be what you need, as it only parses... but it's simple, and small, and easily understandable....
so maybe you can take this and entend it into whatever you need...
this isn't really a class but a static library meant to be called ala.
XML::getTree()
/// wrapped up all pretty by [email]ednark@linuxmail.org[/email]
class XML
{
// by: [email]farinspace@hotmail.com[/email]
function getTree( $filename )
{
$data = implode('', file($filename));
// by: [email]waldo@wh-e.com[/email] - trim space around tags not within
$data = eregi_replace(">"."[[:space:]]+"."<","><",$data);
// begin the good stuff
$p = xml_parser_create();
// by: [email]anony@mous.com[/email] - meets XML 1.0 specification
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
xml_parse_into_struct($p, $data, $vals, $index);
xml_parser_free($p);
$i = 0;
$tree = array();
$tree[] = array(
'tag' => $vals[$i]['tag'],
'attributes' => $vals[$i]['attributes'],
'value' => $vals[$i]['value'],
'children' => XML::getChildrenNodes($vals, $i)
);
return $tree;
}
// by: [email]farinspace@hotmail.com[/email]
function getChildrenNodes($vals, &$i) {
$children = array();
$size_of_vals = sizeof($vals)
while (++$i < $size_of_vals) {
// compair type
switch ($vals[$i]['type']) {
case 'cdata':
$children[] = $vals[$i]['value'];
break;
case 'complete':
$children[] = array(
'tag' => $vals[$i]['tag'],
'attributes' => $vals[$i]['attributes'],
'value' => $vals[$i]['value']
);
break;
case 'open':
$children[] = array(
'tag' => $vals[$i]['tag'],
'attributes' => $vals[$i]['attributes'],
'value' => $vals[$i]['value'],
'children' => XML::getChildrenNodes($vals, $i)
);
break;
case 'close':
return $children;
} /// switch
} /// while
} /// getChildrenNodes
}