protected function _xmlToArray(DOMElement $data)
    {
        $temporaryData = [];

        /** @var $node DOMElement */
        foreach ($data->childNodes as $node) {
            $nodeName           = $this->_stringToIntegerKey($node->nodeName);
            $nodeData           = [];
            $unSerializedData   = [];

            if ($node->hasAttributes() && $node->getAttribute('serialized_object')) {
                try {
                    $unSerializedData = Serializer::unserialize($node->nodeValue);
                } catch (ExceptionInterface $exception) {
                    $this->_addException($exception);
                }

                $temporaryData[$nodeName] = $unSerializedData;
                continue;
            }

            if ($node->hasAttributes()) {
                foreach ($node->attributes as $key => $value) {
                    $nodeData['@attributes'][$key] = $value->nodeValue;
                }
            }

            if ($node->hasChildNodes()) {
                $childNodesData = [];

                /** @var $childNode DOMElement */
                foreach ($node->childNodes as $childNode) {
                    if ($childNode->nodeType === 1) {
                        $childNodesData = $this->_xmlToArray($node);
                    }
                }

                if (!empty($childNodesData)) {
                    $temporaryData[$nodeName] = $childNodesData;
                    continue;
                }
            }

            if (!empty($nodeData)) {
                $temporaryData[$nodeName] = array_merge(
                    [$node->nodeValue],
                    $nodeData
                );
            } else {
                $temporaryData[$nodeName] = $node->nodeValue;
            }
        }

        return $temporaryData;
    }
protected function _xmlToArray(DOMElement $data)
    {
        $temporaryData = [];

        /** @var $node DOMElement */
        foreach ($data->childNodes as $node) {
            $nodeName           = $this->_stringToIntegerKey($node->nodeName);
            $nodeData           = [];
            $unSerializedData   = [];

            if ($node->hasAttributes() && $node->getAttribute('serialized_object')) {
                try {
                    $unSerializedData = Serializer::unserialize($node->nodeValue);
                } catch (ExceptionInterface $exception) {
                    $this->_addException($exception);
                }

                $temporaryData[$nodeName] = $unSerializedData;
                continue;
            }

            if ($node->hasAttributes()) {
                foreach ($node->attributes as $key => $value) {
                    $nodeData['@attributes'][$key] = $value->nodeValue;
                }
            }

            if ($node->hasChildNodes()) {
                $childNodesData = [];

                /** @var $childNode DOMElement */
                foreach ($node->childNodes as $childNode) {
                    if ($childNode->nodeType === 1) {
                        $childNodesData = $this->_xmlToArray($node);
                    }
                }

                if (!empty($childNodesData)) {
                    $temporaryData[$nodeName] = $childNodesData;
                    continue;
                }
            }

            if (!empty($nodeData)) {
                $temporaryData[$nodeName] = array_merge(
                    [$node->nodeValue],
                    $nodeData
                );
            } else {
                $temporaryData[$nodeName] = $node->nodeValue;
            }
        }

        return $temporaryData;
    }
protected function _xmlToArray ( DOMElement $ data ) { $ temporaryData = [ ] ; /** @var $node DOMElement */ foreach ( $ data -> childNodes as $ node ) { $ nodeName = $ this -> _stringToIntegerKey ( $ node -> nodeName ) ; $ nodeData = [ ] ; $ unSerializedData = [ ] ; if ( $ node -> hasAttributes ( ) && $ node -> getAttribute ( 'serialized_object' ) ) { try { $ unSerializedData = Serializer :: unserialize ( $ node -> nodeValue ) ; } catch ( ExceptionInterface $ exception ) { $ this -> _addException ( $ exception ) ; } $ temporaryData [ $ nodeName ] = $ unSerializedData ; continue ; } if ( $ node -> hasAttributes ( ) ) { foreach ( $ node -> attributes as $ key => $ value ) { $ nodeData [ '@attributes' ] [ $ key ] = $ value -> nodeValue ; } } if ( $ node -> hasChildNodes ( ) ) { $ childNodesData = [ ] ; /** @var $childNode DOMElement */ foreach ( $ node -> childNodes as $ childNode ) { if ( $ childNode -> nodeType === 1 ) { $ childNodesData = $ this -> _xmlToArray ( $ node ) ; } } if ( ! empty ( $ childNodesData ) ) { $ temporaryData [ $ nodeName ] = $ childNodesData ; continue ; } } if ( ! empty ( $ nodeData ) ) { $ temporaryData [ $ nodeName ] = array_merge ( [ $ node -> nodeValue ] , $ nodeData ) ; } else { $ temporaryData [ $ nodeName ] = $ node -> nodeValue ; } } return $ temporaryData ; }
recurrent function to travel on xml nodes and set their data as object data

@param DOMElement $data
@return array
recurrent function to travel on xml nodes and set their data as object data