php - Add DocType to exits DomDocument -
i have php class likes "extension_domdocument" , extends php "domdocument" class.
i create new object of extension_domdocument , add doctype object.
my code is:
// $this->data array convert array xml $objcdom = new extension_domdocument('1.0', 'utf-8'); $objcdom->frommixed($this->data); how can add doctype $objcdom?
thank you!
you can use the dom implementation create document type object. document type objects still dom nodes. can append them existing document.
class mydomdocument extends domdocument {} $dom = new mydomdocument(); $implementation = new domimplementation(); $dom->appendchild($implementation->createdocumenttype('example')); $dom->appendchild($dom->createelement('foo')); echo $dom->savexml(); output:
<?xml version="1.0"?> <!doctype example> <foo/>
Comments
Post a Comment