Release 1.4 of the SDK introduced capabilities for processing Extensible Markup Language (XML) documents as part of the standard set of class libraries. These are collectively referred to as JAXP, the Java API for XML. In this chapter and the next we will be exploring not only how we can read XML documents, but also how we 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 we will discuss the second approach to reading XML documents, as well as how we can modify them and create new ones. Inevitably, we can only skim the surface in a lot of areas since 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 will 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 different.
How you read documents using SAX