Java Reference
In-Depth Information
Using XML
One of Java's main selling points is that the language produces programs that can run on
different operating systems without modification. The portability of software is a big
convenience in today's computing environment, where Windows, Linux, Mac OS, and a
half dozen other operating systems are in wide use and many people work with multiple
systems.
XML, which stands for Extensible Markup Language, is a format for storing and orga-
nizing data that is independent of any software program that works with the data.
Data that is compliant with XML is easier to reuse for several reasons.
First, the data is structured in a standard way, making it possible for software programs
to read and write the data as long as they support XML. If you create an XML file that
represents your company's employee database, there are several dozen XML parsers that
can read the file and make sense of its contents.
This is true no matter what kind of information you collect about each employee. If your
database contains only the employee's name, ID number, and current salary, XML
parsers can read it. If it contains 25 items, including birthday, blood type, and hair color,
parsers can read that, too.
Second, the data is self-documenting, making it easier for people to understand the pur-
pose of a file just by looking at it in a text editor. Anyone who opens your XML
employee database should be able to figure out the structure and content of each
employee record without any assistance from you.
This is evident in Listing 19.1, which contains an RSS file. Because RSS is an XML
dialect, it is structured under the rules of XML.
LISTING 19.1
The Full Text of workbench.rss
1: <?xml version=”1.0” encoding=”utf-8”?>
2: <rss version=”2.0”>
3: <channel>
4: <title>Workbench</title>
5: <link>http://www.cadenhead.org/workbench/</link>
6: <description>Programming, publishing, politics, and popes</description>
7: <docs>http://www.rssboard.org/rss-specification</docs>
8: <item>
9: <title>Toronto Star: Only 100 Blogs Make Money</title>
10: <link>http://www.cadenhead.org/workbench/news/3132</link>
11: <pubDate>Mon, 26 Feb 2007 11:30:57 -0500</pubDate>
12: <guid isPermaLink=”false”>tag:cadenhead.org,2007:weblog.3132</guid>
13: <enclosure length=”2498623” type=”audio/mpeg”
 
Search WWH ::




Custom Search