Chapter 22

Java and XML


  • 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

The Java Development Kit (JDK) includes capabilities 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 explore 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 mechanisms you have available for this. In the next chapter I discuss how you can modify XML documents 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.


XML, or the Extensible Markup Language, is a system- and hardware-independent language for defining data and its structure within an XML document. An XML document is a Unicode text file that contains data ...

Get Ivor Horton's Beginning Java®, Java 7 Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.