protected function arrayToDomNode(\DOMDocument $dom, \DOMElement $node, array $arr)
    {
        foreach ($arr as $key => $item) {
            $ref = null;
            if (is_numeric($key) || empty($key)) {
                if (is_numeric($key)) {
                    $ref = $key;
                }
                $key = 'item';
            }
            if (is_array($item)) {
                $newNode = $dom->createElement($key);
                if (!is_null($ref)) {
                    $attr = $dom->createAttribute('ref');
                    $attr->value = $ref;
                    $newNode->appendChild($attr);
                }
                $this->arrayToDomNode($dom, $newNode, $item);
                $node->appendChild($newNode);
            } elseif (is_object($item)) {
                $this->encodeObject($key, $item, $dom, $node);
            } else {
                $node->appendChild($dom->createElement($key, $item));
            }
        }
    }