Following methods were added in DOM Level 2 which helps in creating XML document:
The createDocument() method creates an XML document of specified type. It takes 3 parameters as inputs:
Syntax for createDocument() method
var xmldoc = document.implementation.createDocument(“”, “root”, null);
The createDocumentType() method creates an empty documentType node. The input parameters are:
The name is the name of the document type to be created, the publicId is an external subset public identifier (if it is not present, ‘null’ can be passed as the second argument), and the systemId is an external subset public identifier. This function returns a new documentType node.
Syntax for createDocumentType() method
var xmldoc = document.implementation.createDocumentType(“list1”, "-//W3C//DTD SVG 1.0//EN", "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd");
The hasFeature() method checks if the DOM implementation has a specific feature and version. It takes feature and version as input paramters. The feature is the feature which has to be checked andthe version is the version of the feature to check against. This function returns a boolean value indicating if the feature is present or not.
Syntax for hasFeature() method
var hasXML = document.implementation. hasFeature(“XML”, “2.0”);