JAVA XML

JavaXml Projects

JavaXml Project 1

JavaXml Examples

JavaXml EXAMPLE

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
.newInstance();
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.

System.setProperty("javax.xml.parsers
.XmlDocumentParserFactory","com.foo.myFactory");

 

Example

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:");
try{
//Firstly create instance of DocumentBuilderFactory
DocumentBuilderFactory fact = DocumentBuilderFactory
	.newInstance();
//Get the DocumentBuilder
DocumentBuilder pars = fact.newDocumentBuilder();
//Create blank DOM Document
Document docu = pars.newDocument();
}catch(Exception e){
System.out.println(e.getMessage());
}
System.out.println("Creation Done...");
System.out.println("Exiting from Document...");
}
}
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: