protected function injectDom(\DOMDocument $dom, \DOMElement $target, \DOMNode $source)
    {
        if ($source->nodeType != XML_ELEMENT_NODE) {
            return;
        }
        $import = $dom->createElement($source->nodeName);

        foreach ($source->attributes as $attr) {
            $import->setAttribute($attr->name, $attr->value);
        }
        foreach ($source->childNodes as $child) {
            $this->injectDom($dom, $import, $child);
        }
        $target->appendChild($import);
    }