$xml = new DomDocument('1.0', 'UTF-8'); $root = $xml->createElement('root'); $xml->appendChild($root); echo $xml->saveXml();
use Laminas\Dom\Document; $xml = new Document(''); $xml->formatOutput = true; echo $xml->saveXML();
This example requires the Laminas Dom package to be installed, which can be done via Composer by running `composer require laminas/laminas-dom`.