|[ Team LiB ]|
Hour 19. Creating an XML Application
What You'll Learn in This Hour:
The Extensible Markup Language (XML) represents an important step in data representation. In the past, programs used many different formats for storing data. There have been text files with comma-delimited or pipe-delimited fields, binary files in any number of formats, and even plain ASCII text. Unfortunately, most programs use slightly different ways to store data, even if the overall format is similar. For example, when you save data in comma-separated fields, how do you specify what each field is? You might save the first name followed by the last name. Another developer might save the last name and then the first name. How do you know the format of the file unless someone tells you? You could put a line at the top of the file explaining what each field is, but even that might have different formats.
Another problem you encounter when storing data is that most representations tend to be tabular in nature. That is, when you write data into a file, you typically put all the information for a particular data element on a single line in the file. What happens when the data you want to write is a Java object with many nested data structures? How can you store all those data structures within a single line, especially if you must stick to a prescribed set of fields?
XML solves this problem by defining a standard way to represent data, a standard way to tag the data with its type, and a standard way to describe the overall data structure. (There isn't room to cover XML in its entirety here. You can learn more about XML from Sams Teach Yourself XML in 21 Days, 3rd edition, by Steve Holzner, ISBN: 0672325764.) XML is very simple, easy to read, and easy to understand. There are a few things XML is not:
|[ Team LiB ]|