<?php
$imp = new DOMImplementation;
$dtd = $imp->createDocumentType('graph', '', 'graph.dtd');
$dom = $imp->createDocument("", "", $dtd);
$dom->encoding = 'UTF-8';
$dom->standalone = false;
$element = $dom->createElement('graph');
$dom->appendChild($element);
echo $dom->saveXML();
?>
The above example will output:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE graph SYSTEM "graph.dtd">
<graph/>