XML Components

Before you dive into using JAXP to manipulate XML files, we need to define the components that make up XML documents.

XML Document

The core of an XML document is the document itself. It consists of the following components:

  • Prolog. Contains version information, comments, and references to Document Type Definition (DTD) files.

  • Body. Contains a document root and sub-elements.

  • Epilog. Contains comments and processing instructions.

Listing 12.1 shows a simple XML file that might be used in a bookstore to define a set of books.

Listing 12.1. books.xml<?xml version="1.0"?>
 <!DOCTYPE books SYSTEM "Books.dtd"> <books> <book category="computer-programming"> <author>Steven Haines</author> <title>Java 2 From Scratch</title> <price>39.95</price> ...

Get Java™ Web Services Unleashed 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.