Easy learning with example program codes

Java dom xml parser

The DOM refers to Document Object Model. The DOM parses the XML file, creates the DOM objects and loads it into the memory in the tree structure.

Note: DOM is simple and easy to use but it consume lots of memory and slow.

Interfaces defined by DOM:

The DOM defines several Java interfaces. Here are the most common interfaces:
1. Document: It represents the entire XML document. A Document object is also known as a DOM tree. The getDocumentElement() method of Document interface returns the root element of the document.
2. Node: It represents the base datatype of the DOM.
Commonly used methods of Node interface:
a. Node.getFirstChild(): It returns the first child of the specified node.
b. Node.getLastChild(): It returns the last child of the specified node.
c. Node.getNextSibling(): It returns the next sibling of the specified node.
d. Node.getPreviousSibling(): It returns the previous sibling of the specified node.
e. Node.getAttribute(attrName): It returns the requested attribute value of the specified node.
3. Element: It represents the object.
4. Attr: It represents the attribute of an element.
5. Text: It represents the actual content of an attribute or element.

Java dom xml parser examples:

Next Topic: DOM XML parser to parse XML file in java.
Previous Topic: XML parser overview.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki