Tree-based access to XML documents with Java using the DOM
The purpose of this assignment was to:
- Learn what the DOM is
- Learn how to use the DOM in Java to access XML documents
The description and my solution of the Tree-based access to XML documents with Java using the DOM - assignment can be viewed at the bottom of this page.
What is DOM?
DOM is short for "Document Object Model".
The DOM is a cross-platform and cross-language interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents.
The DOM provides a set of objects for HTML and XML documents, and an interface for accessing and manipulating them.
The DOM is separated into different blocks:
- Core DOM(set of objects for any structured document)
- XML DOM(set of objects for XML documents)
- HTML DOM(set of objects for HTML documents )
And different levels:
DOM Level 1:
HTML and XML document models. Has functionality for document navigation and document manipulation.
Like level 1, but with a style sheet object model. Functionality for manipulating a documents style information.
DOM Level 3 have content models for DTD, XML Schemas and document validation. It also specifies document loading and saving, document views, document formatting, and key events.
Java and the DOM - language bindings
When using DOM for a specific programming language interfaces and classes that implement the DOM itself is needed.
Because the methods aren't outlined specifically in the DOM specification, language bindings must be developed to represent the conceptual structure of the DOM for its use in Java or any other programming language.
These language bindings function as APIs used for manipulating documents as specified in the DOM specification. The latest Java Bindings can be viewed and/or downloaded from Java Bindings
The application should be able to be started from the command prompt like this:
java DOMEcho <xml-document>
java DOMEcho cv-template.xml