- XML DOM Basics
- XML DOM - Home
- XML DOM - Overview
- XML DOM - Model
- XML DOM - Nodes
- XML DOM - Node Tree
- XML DOM - Methods
- XML DOM - Loading
- XML DOM - Traversing
- XML DOM - Navigation
- XML DOM - Accessing
- XML DOM Operations
- XML DOM - Get Node
- XML DOM - Set Node
- XML DOM - Create Node
- XML DOM - Add Node
- XML DOM - Replace Node
- XML DOM - Remove Node
- XML DOM - Clone Node
- XML DOM Objects
- DOM - Node Object
- DOM - NodeList Object
- DOM - NamedNodeMap Object
- DOM - DOMImplementation
- DOM - DocumentType Object
- DOM - ProcessingInstruction
- DOM - Entity Object
- DOM - EntityReference Object
- DOM - Notation Object
- DOM - Element Object
- DOM - Attribute Object
- DOM - CDATASection Object
- DOM - Comment Object
- DOM - XMLHttpRequest Object
- DOM - DOMException Object
- XML DOM Useful Resources
- XML DOM - Quick Guide
- XML DOM - Useful Resources
- XML DOM - Discussion
DOM - DOMImplementation Object Method - createdocument
The method createDocument () is used to create a DOM Document object of the specified type with its document element.
Syntax
Following is the syntax of the createDocument () method.
Document doc = document.implementation.createDocument (namespaceURI, qualifiedNameStr, documentType);
namespaceURI is the namespace URI of the document element to be created or null.
qualifiedName is the qualified name of the document element to be created or null.
doctype is the type of document to be created or null.
This method returns a new Document object with its document element.
Example
Following example demonstrates the usage of the createDocument () method −
<!DOCTYPE html> <html> <body> <script> var doc = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null); var body = document.createElementNS('http://www.w3.org/1999/xhtml', 'body'); body.setAttribute('id', 'Company'); doc.documentElement.appendChild(body); document.write(doc.getElementById('Company')); // [object HTMLBodyElement] </script> </body> </html>
Execution
Save this file as domimplementation_createdocument.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 −
[object HTMLBodyElement]
dom_domimplementation_object.htm
Advertisements
To Continue Learning Please Login
Login with Google