XML and Java

Now that you understand XML basics, let's take a look at how we can use XML and Java together. There have been many Java parsers developed to interact with XML documents. The three most common have been developed by Sun Microsystems, IBM, and Microsoft. For our example, we will be using Sun's Java API for XML parsing, which can be downloaded from the following URL:

http://java.sun.com/xml/download.html

Follow the installation instructions for your platform, including adding the jaxp.jar and the parser.jar files to your classpath.

Sun's API is composed of two core components, the Document Object Model (DOM) and the Simple API for XML (SAX API). The DOM is a tree-based API, and the SAX is an event-based API. For our examples, we will ...

Get Pure Java Server Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.