Advantages of XML

Using XML to exchange information offers many benefits.

Advantages of XML include the following:

  • XML uses human, not computer, language. XML is readable and understandable, even by novices, and no more difficult to code than HTML.
  • XML is completely compatible with Java™ and 100% portable. Any application that can process XML can use your information, regardless of platform.
  • XML is extendable. Create your own tags, or use tags created by others, that use the natural language of your domain, that have the attributes you need, and that makes sense to you and your users.

The following example illustrates, in a simplified way, the readability and extensibility of XML:

HTML example XML example
<HTML>
<H1 ID="MN">State</H1>
<H2 ID="12">City</H2>
<DL>
  <DT>Name</DT>
    <DD>Johnson</DD>
  <DT>Population</DT>
    <DD>5000</DD>
</DL>
<H2 ID="15">City</H2>
<DL>
  <DT>Name</DT>
    <DD>Pineville</DD>
  <DT>Population</DT>
    <DD>60000</DD>
</DL>
<H2 ID="20">City</H2>
<DL>
  <DT>Name</DT>
    <DD>Lake Bell</DD>
  <DT>Population</DT>
    <DD>20</DD>
</DL>
</HTML>

<?XML VERSION="1.0" STANDALONE="yes" ?>
<STATE STATEID="MN">
  <CITY CITYID="12">
    <NAME>Johnson</name>
    <POPULATION>5000</POPULATION>
  </CITY>
  <CITY CITYID="15">
    <NAME>Pineville</NAME>
    <POPULATION>60000</POPULATION>
  </CITY>
  <CITY CITYID="20">
    <NAME>Lake Bell</NAME>
    <POPULATION>20</POPULATION>
  </CITY>
</STATE>

HTML tag names reveal nothing about the meaning of their content. The example above uses an HTML definition list, but the problems inherent in using HTML occur if the data were contained in a table or some other kind of HTML tags. Examples follow:

  • Many of the HTML tags are acronyms, so they are not as readable as common language.
  • HTML tags represent data (in this example, city names and populations) as items to display, for example, as definitions in a list or cells in a table. This makes it difficult to manipulate the data or to exchange it between applications.

The XML tag names are readable and convey the meaning of the data. The information structure is easily discerned by both humans and computers as each XML tag immediately precedes the associated data. The data structure follows a noticeable and useful pattern, making it easy to manipulate and exchange the data.