Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
XML
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Create an Empty DOM Document

                         

This Example shows how to create an empty DOM Document . JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used to create new DOM parsers. There are some of the methods used in code given below for creating an empty DOM Document :-

DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance():- This method Creates a DocumentBuilder Factory .DocumentBuilder Factory is a Class that enables application to obtain parser for building DOM trees from XML Document

DocumentBuilder builder = Factory.newDocumentBuilder():- This method creates a DocumentBuilder object with the help of a DocumentBuilderFactory

Document doc = builder.newDocument():- This method obtain a new instance of a DOM Document object to build a DOM tree.

Element element=doc.getDocumentElement():- By this method we can have direct access to the root of the DOM Document.


CreatingEmptyDomDocument.java:-

/* 
 * @Program to Create an Empty DOM Document 
 * CreatingEmptyDomDocument.java 
 * Author:-RoseIndia Team
 * Date:-17-July-2008
 */
import java.io.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

public class CreatingEmptyDomDocument {

    public static void main(String[] args) throws Exception {

        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();

        DocumentBuilder builder = builderFactory.newDocumentBuilder();

        Document doc = builder.newDocument();

        new CreatingEmptyDomDocument().emptydom(doc);
    }
    public void emptydom(Document doc){

        Element element=doc.getDocumentElement();

        System.out.println("Value of the root of Dom Document created is:"+element);

        System.out.print("DOM Document created Successfully");
    }
}


Output of the program:-

Value of the root of Dom Document created is: null
DOM Document created Successfully


Download Source Code

 

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
Pie Chart
first application of s
à¹?à¸?à¸?à¹?à¸????à¹?à
flex tutorial
hibernate project
backing beans
Calendar
Easy Java Tutorial
Photoshop Basics Repla
video in flash
links within action fo
Ñ?Ð?Ð?Ñ?Ð???Ñ?Ð?Ð?Т 
xml with jsp
JavaScript
ecosurePortalUnsavedDa
3DS MAX Basics First L
precision and accuracy
insert query using whe
what is contextpath
droping column in tabl
tuxedo
javascript to move a t
public void actionPerf
Bubble sort with two n
join tables using SQL
c:out in var of c:fore
Component Diagram
chart in servlet
Custom Rendering of JL
insert image in pdf
J2ME Code Camp
pass textbox value fro
how to design the stan
retriving multiple ima
configu.struts.xml
Linux Caixa M? ???? 
ajax with jsp chat
create GUI in java pro
phases of java program
bubble sort code
breakะà?à¸?????ะà?
inhertence codes in ja
convert string to asci
string
render a value
message board
how to redirect to oth
string object
select database with p
jsp standard action ta
TCP Examples in swing
Photoshop Basics Cutti
javasrciprt to move a
how to pass same varia
send emails with jsp
Send SMS using JAva
vb examlpe
set cell weidth
?ั???ะà¸?à¹??????à
Topic
com.mysql.jdbc.Driver
ajax prototype framewo
jasperreport
Boolean
jasper report
java applet
ะ�ย�?ะ�ะ
core java Applets
connection
show input box
Session in Servlet
mySQL 5.0 installation
java random numbers
square roots
store list in database
Linux Caixa MС???????
two submit buttons at
sqlserver 2005 tomcat
3DS MAX Effects Cell S
display blob in struts
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.