Hello folks! welcome back to a new edition of our tutorial on XML DOM. In this tutorial, we are going to be studying about the XML DOM createDocumentType Method.
The createDocumentType method creates an empty DocumentType node.
Note: Entity declarations and notations are not available.
The createDocumentType method creates an empty DocumentType node.
Note: Entity declarations and notations are not available.
Syntax
The following below is the syntax to use the XML DOM createDocumentType Method -
Document doc = document.implementation.createDocumentType(qualifiedName, publicId, systemId);
Parameter Details
- qualifiedName is the qualified name of the document element to be created.
- publicId is the external subset public identifier.
- systemId external subset system identifier.
- It returns a new DocumentType with Node.ownerDocument set to null.
Example
The following example illustrates 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>
Output
Save this file as domimplementation_createdocumenttype.html on the server path (this file and node.xml should be on the same path in your server). This gives us the following output below -
-//W3C//DTD SVG 1.1//EN
Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we will be studying about XML DOM hasFeature Method.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.