
Java DOM Document Object Model is a commendation of the World Wide Web Consortium. It explains an interface that enables programs to access and modify
the style, structure, and content of XML documents.
XML parser that support DOM implement this interface.
It can be clearly perceive from the image provide below as follows.
When should one use a DOM parser?
Use it when you know a lot about the structure of a document.
Use it if you need to use the information in an XML document more than once.
You need to move parts of an XML document around.
What do we get by using DOM?
When an XML document is parse with DOM parser.
it gives back a tree structure that contains all the element of the document.
A variety of function are provide by DOM you can use it to inspect.
the content and structure of the document.
Let us discuss the advantages of DOM as listed below:
What do we get by using DOM?
Used for manipulating document structures.
Data persists in memory.
You can go forward and backward in the tree (random access)
You can make change directly to the tree in memory.
DOM Interface
What do we get by using DOM?
Node: The DOM Node interface is an abstract base class upon which many other DOM API object are base.
thus letting those object type be use similarly and often interchangeably.
Element: It represent a program element such as a package, class, or method.
Attr: it is use for representing an attribute of an element.
Text: It is the actual content of an Element or Attr.
Document: Document represent the entire XML document.