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

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -