Chapter 22. Java and XML

The Java Development Kit (JDK) includes capabilities within the standard set of class libraries for processing Extensible Markup Language (XML) documents. The classes that support XML processing are collectively referred to as JAXP, the Java API for XML Processing. In this chapter and the next you'll be exploring not only how you can read XML documents, but also how you can create and modify them. This chapter provides a brief outline of XML and some related topics, plus a practical introduction to reading XML documents from within your Java programs using one of the two available mechanisms for this. In the next chapter I'll discuss the second approach to reading XML documents, as well as how you modify them and how you create new XML documents programmatically. Inevitably, I can only skim the surface in a lot of areas because XML itself is a huge topic. However, you should find enough in this chapter and the next to give you a good feel for what XML is about and how you can handle XML documents in Java.

In this chapter you'll learn:

  • What a well-formed XML document is

  • What constitutes a valid XML document

  • What the components in an XML document are and how they are used

  • What a DTD is and how it is defined

  • What namespaces are and why you use them

  • What the SAX and DOM APIs are and how they differ

  • How you read documents using SAX

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition 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.