PHP DOM array - cut the first element - better way to do it

mao1990

New Member
I'm really stucked and don't know how to implement an idea better. So, we have an XML file:
CxBWh.png
I've got an array by function dom_to_array()\[code\]function dom2array($node) {$result = array(); if($node->nodeType == XML_TEXT_NODE) { $result = $node->nodeValue; } else { if($node->hasAttributes()) { $attributes = $node->attributes; if(!is_null($attributes)) foreach ($attributes as $index=>$attr) $result[$attr->name] = $attr->value; } if($node->hasChildNodes()){ $children = $node->childNodes; for($i=0;$i<$children->length;$i++) { $child = $children->item($i); if($child->nodeName != '#text') if(!isset($result[$child->nodeName])) $result[$child->nodeName] = $this->dom2array($child); else { $aux = $result[$child->nodeName]; $result[$child->nodeName] = array( $aux ); $result[$child->nodeName][] = $this->dom2array($child); } } } } return $result; \[/code\]}I've got an array with first XML element - STRUCTURE. Array
--STRUCTURE
----PAGE
----PAGE
-- -- --PAGE
----PAGE
So the main question is how make array looks like this:Array
----PAGE
----PAGE
-- -- --PAGE
----PAGE
How to do it better friends - i don't need to include "structure" into array, is it possible to create by DOM functions ?!
 
Back
Top