public function appendContentToElement(\DOMNode $toElement) { $dom = $this->toXml(true); $child = $dom->firstChild; while ($child !== null) { $toElement->appendChild($toElement->ownerDocument->importNode($child, true)); $child = $child->nextSibling; } return $toElement; }