DocumentBuilder getDOMImplementation() Method
Description
The Javax.xml.parsers.DocumentBuilder.getDOMImplementation() method obtains an instance of a DOMImplementation object.
Declaration
Following is the declaration for Javax.xml.parsers.DocumentBuilder.getDOMImplementation() method
public abstract DOMImplementation getDOMImplementation()
Parameters
NA
Return Value
This method returns a new instance of a DOMImplementation.
Exception
NA
Example
For our examples to work, a xml file named Student.xml is needed in our CLASSPATH. The contents of this XML are the following −
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <student id="10"> <age>12</age> <name>Malik</name> </student>
The following example shows the usage of Javax.xml.parsers.DocumentBuilder.getDOMImplementation() method.
package com.tutorialspoint;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.DOMImplementation;
public class DocumentBuilderDemo {
public static void main(String[] args) {
// create a new DocumentBuilderFactory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
// use the factory to create a documentbuilder
DocumentBuilder builder = factory.newDocumentBuilder();
// get the DOMImplementation object
DOMImplementation a = builder.getDOMImplementation();
// print the DOMImplementation Object
System.out.println("" + a);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
If we compile the code and execute it, this will produce the following result −
com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl@7f971afc
javax_xml_parsers_documentbuilder.htm
Advertisements