DOM - DOMImplementation Object Method - createdocument


Advertisements

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

Syntax

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.

Example

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

<!DOCTYPE html>
<html>
   <body>
      <script>
         var dt = document.implementation.createDocumentType('svg:svg', 
            '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
         var d = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', dt);
         document.write(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN
      </script>
   </body>
</html>

Execution

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
dom_domimplementation_object.htm
Advertisements