You are here: Reference > JavaScript > client-side > HTML DOM > methods > createDocumentType (implementation)
createDocumentType method (implementation)
9 | ||||
Creates a new doctype object.
Note: The createDocumentType method is supported in Internet Explorer from version 9.
When the new doctype object is created, it can be used for the createDocument method to specify the document type for a new XML document or it can be inserted into an XML document with the insertBefore or replaceChild method.Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. String that specifies the name of the document type. | |||||||
Required. String that specifies the public identifier for the document type element. | |||||||
Required. String that specifies the system identifier for the document type element. |
Return value:
Returns the newly created doctype object.
Example HTML code 1:
This example illustrates the use of the createDocumentType method:
|
||||
<head> <script type="text/javascript"> function CreateXMLDoc () { if (document.implementation.createDocument && document.implementation.createDocumentType) { var fruitDocType = document.implementation.createDocumentType ("fruit", "SYSTEM", "<!ENTITY tf 'tropical fruit'>"); var xmlDoc = document.implementation.createDocument ("", "fruits", fruitDocType); var fruitNode = xmlDoc.createElement ("fruit"); fruitNode.setAttribute ("name" , "avocado"); xmlDoc.documentElement.appendChild (fruitNode); var serializer = new XMLSerializer(); alert (serializer.serializeToString (xmlDoc)); } else { alert ("Your browser does not support this example"); } } </script> </head> <body> <button onclick="CreateXMLDoc ();">Create an XML document with document type!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments