DOM - DOMImplementation Object Method - createdocument


The method createDocumentType () is used to create an empty DocumentType node. Entity declarations and notations are not made available.


Following is the syntax of the createDocument () method.

Document doc = document.implementation.createDocumentType(qualifiedName, publicId, systemId);
  • qualifiedName is the qualified name of the document type to be created.

  • publicId is the external subset public identifier.

  • systemId external subset system identifier.

  • This method returns a new DocumentType node with Node.ownerDocument set to null.


Following example demonstrates the usage of the createDocumentType () method −

<!DOCTYPE html>
         var dt = document.implementation.createDocumentType('svg:svg', 
            '-//W3C//DTD SVG 1.1//EN', '');
         var d = document.implementation.createDocument('', 'svg:svg', dt);
         document.write(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN


Save this file as domimplementation_createdocumenttype.htm on the server path (this file and node.xml should be on the same path in your server). We will get the output as shown below −

-//W3C//DTD SVG 1.1//EN