logger = $logger; $document = new \DOMDocument(static::XML_VERSION, static::XML_ENCODING); $document->loadXML($content); $this->templateNode = $document->documentElement; } /** * Get template root element * * @return \DOMElement */ public function getDocumentElement() { return $this->templateNode; } /** * Append * * @param string $content * @return void */ public function append($content) { $newFragment = $this->templateNode->ownerDocument->createDocumentFragment(); $newFragment->appendXML($content); $this->templateNode->appendChild($newFragment); } /** * Returns the string representation * * @return string */ public function __toString() { try { $this->templateNode->ownerDocument->normalizeDocument(); $result = $this->templateNode->ownerDocument->saveHTML(); } catch (\Exception $e) { $this->logger->critical($e->getMessage()); $result = ''; } return $result; } }