XML is a flexible meta-language that allows you to design markup
languages to fit your documents rather than the one-size-fits-all
approach of HTML. XML is suitable not only for Web pages, but also for
application file formats, object serialization, and data interchange
between applications. This tutorial will show you how to use Java to
process XML documents and show you why you might want to do that.
XML files are text files so you'll explore how Java outputs text
using Writers and how to use these classes to write XML. Then you'll see
some demonstrations of the conversion of existing data formats to XML.
Of course writing data is only half of the I/O equation so next you'll
learn how to read XML documents from Java. Input is considerably more
complicated than output. Fortunately 90% of the work can be done for you
by free parsers like the Apache Project's Xerces. You'll see how to use
the standard, event based Simple API for XML (SAX) to drive your own
programs through callbacks.
Most parsers also support a more object oriented view of an XML document
by implementing the W3C's Document Object Model (DOM). You'll
investigate the DOM in depth, see how it compares to SAX, and learn
which API is appropriate for which tasks.
Outline:
- Text I/O in Java
- Writing XML with Java
- Reading XML with SAX2
- Reading XML with DOM2
Prerequisites:
Students should be completely comfortable programming in Java, should
have at least a user's understanding of the Internet, and should be
familiar with XML Basics.