JavaXml Projects

JavaXml Project 1

JavaXml Examples


Creating Blank Document DOM
Previous Home Next

In this tutorials we are going to create the blank document. JAXP is an interface of java which provide the standard approach to parsing XML document. for creating the blank document we use the BuilderFactory to create the DocumentBuilder Class with the JAXP. In XML the DocumentBuilderFactory is used to create the new Document object model parser.

DocumentBuilderFactory fact = DocumentBuilderFactory
DocumentBuilder pars = fact.newDocumentBuilder();
Document docu = pars.parse(myInputSource);

The parse function is used to parse existing xml document.

DocumentBuilderFactory is use for the access to system property javax.xml.parsers.XmlDocumentParserFactory .
this property is help to find the class to load. So we can change the parser by calling.



package r4r;
import org.w3c.dom.*;
import javax.xml.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class blankdoctest {
public static void main(String[] args)
System.out.println("Creation of Balnk Document:");
//Firstly create instance of DocumentBuilderFactory
DocumentBuilderFactory fact = DocumentBuilderFactory
//Get the DocumentBuilder
DocumentBuilder pars = fact.newDocumentBuilder();
//Create blank DOM Document
Document docu = pars.newDocument();
}catch(Exception e){
System.out.println("Creation Done...");
System.out.println("Exiting from Document...");
Previous Home Next