diff --git a/src/XmlConstructor.php b/src/XmlConstructor.php index c87c3cf..ea3ea51 100644 --- a/src/XmlConstructor.php +++ b/src/XmlConstructor.php @@ -161,12 +161,12 @@ public function toOutput() throw new RuntimeException('The constructor is closed. You have to create new one to flush its again.'); } + $this->flushed = true; + if ($this->hasDocumentStart) { $this->document->endDocument(); } - $this->flushed = true; - return $this->document->outputMemory(); }