ownerDocument->importNode($domFrom, TRUE); $domTo->appendChild($tmp); } protected function _process ( $key, $tmp, $fields, $xml ) { if ( is_numeric($key) ) $key = "item"; $newObj = new SimpleXMLElement("<$key/>"); $newObj = $this->_convert( $tmp, $newObj, $fields ); $this->addNode($newObj, $xml); } protected function _convert( Varien_Object $data, SimpleXMLElement $xml, $fields = array() ) { $data = $data->getData(); foreach ( $data as $key => $value ) { if ( is_scalar($value) ) { $xml->addChild($key,$value); } if ( is_array($value) ) { $tmp = new Varien_Object(); $tmp->setData($value); $this->_process($key,$tmp,$fields,$xml); } if ( is_object($value) && $value instanceof Varien_Object ) { $tmp = $value; $this->_process($key,$tmp,$fields,$xml); } } return $xml; } public function convert ( Varien_Object $data, $root = '', $fields = array() ) { $xml = new SimpleXMLElement($root); return $this->_convert($data, $xml, $fields ); } }