15.1. Why Use XML for Data?
Before XML, individual programmers had to determine how data would be
formatted whenever they needed to store or transmit program data. In
most cases, the data was never intended for use outside the original
program, so programmers would store it in the most convenient format
they could devise. A few de facto file formats evolved over the years
(RTF, CSV, and the ubiquitous Windows .ini file
format), but the data written by one program could usually be read
only by that same program. In fact, it was often possible for only
that specific version of the same program to
read the data.
The rapid proliferation of XML and free XML tools throughout the
programming community has given developers an obvious choice when the
time comes to select a data-storage or transmission format for their
application. For all but the most trivial applications, the benefits
of using XML to store and retrieve data far outweigh the additional
overhead of including an XML parser in your application. The unique
strengths of using XML as a software data format include:
- Simple syntax
-
Easy to generate and parse.
- Support for nesting
-
Tags easily allow programs to represent structures with nested
elements.
- Easy to debug
-
Human-readable data format is easy to explore and create with a basic
text editor.
- Language and platform independent
-
XML and Unicode guarantee that your datafile will be portable across
virtually every popular computer architecture and language
combination in use today.
Building on these basic strengths, XML can make possible new types of
applications that would have been previously impossible (or very
costly) to implement.