Hi,

Did some more tweaking and if we create a new element for each node
ther is no need to clone, saves a few lines of code :)

function parseBranch($branch, &$doc, &$parent)
{
        foreach ($branch as $key => $val) { 
                switch ($key) { 
                        // parent attributes 
                        case ('ATTRIBUTES'): 
                                foreach ($val as $attrName => $attrVal) {
                                        switch ($attrName){
                                                case 'VALUE':
                                                        $nodeValue  = 
$doc->create_text_node($attrVal);
                                                        $parentValue = 
$parent->append_child($nodeValue); 
                                                break;
                                                default:
                                                        
$parent->set_attribute($attrName, $attrVal);
                                                break;
                                        }
                                } 
                        break; 
                        // parent value 
                        case ('VALUE'): 
                                $nodeValue  = $doc->create_text_node($val); 
                                $parentValue = $parent->append_child($nodeValue); 
                        break; 
                        default: 
                                // parse children of this node 
                                foreach ($val as $children) {
                                        //create node
                                        $node = $doc->create_element($key);
                                        $child = $parent->append_child($node);
                                        //set is elements
                                        parseBranch($children, $doc, $child); 
                                } 
                        break; 
                } 
        } 
}





-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to