Pin Me

An Introduction to XML - Part 2

written by: Dr. Crystal Cooper•edited by: Michele McDonough•updated: 7/5/2011

This article presents the second part of An Introduction to XML, with a brief look at how XML differs from HTML.

  • slide 1 of 5

    XML Versus HTML

    XML and HTML are siblings, yet they are very different. Female Boxer Like HTML, XML is text-based, and uses tags, elements, and attributes. However, the focus of HTML is on the display of content, whereas XML is designed to emphasize the content itself. Because HTML's strength is in displaying and formatting information, you are not able to use it for creating or modifying content like you can with XML. Neither is it extensible in the way XML is, because you cannot add tags.

  • slide 2 of 5

    Table Example

    For example, how would you code a catalog of books in HTML? Perhaps you would use a table:







    <TD>Honore de Balzac</TD>

    <TD>Charles Dickens</TD>



    <TD>Cousin Bette</TD>

    <TD>Little Dorrit</TD>



    The HTML document presents the data in rows and columns, and we may easily add extra formatting to control font size, cell color, and other markups. The tags format the information, but cannot describe it, and are incapable of being altered to meet specific requirements. Additionally, they are the same for every document.

    Consider the same information displayed in XML format:



    <AUTHOR>Honore de Balzac</AUTHOR>

    <TITLE>Cousin Bette</TITLE>



    <AUTHOR>Charles Dickens</AUTHOR>

    <TITLE>Little Dorrit</TITLE>



    In contradistinction to the HTML code above, the XML document is focused on adding structure to the data in the form of elements. The elements describe what the data actually is. We know that our document must be a book catalog and that it must specify authors and titles.

  • slide 3 of 5

    An Example Using Lists

    Now let's consider a list with a partial table of contents rendered in HTML:

    <H2>Tales of Unrest</H2>

    <H3>Joseph Conrad</H3>


    <LI>Karain: A Memory</LI>

    <LI>The Idiots</LI>


    In XML, one solution from many possibilities could be:

    <TITLE>Tales of Unrest</TITLE>

    <AUTHOR>Joseph Conrad</AUTHOR>


    <CHAPTER>Karain: A Memory</CHAPTER>

    <CHAPTER>The Idiots</CHAPTER>


    So we can observe that the main focus of the XML code is on the content, and not on the presentation per se. The presentation of an XML document will be addressed in a future article.

  • slide 4 of 5

    For Further Reading

    The best way to learn XML is by doing as many exercises as possible. Some texts you may wish to consider are:

    • XML: Visual QuickStart Guide (2nd Edition) by Kevin Howard Goldberg
    • New Perspectives on XML by Patrick Carey
    • Beginning XML by Hunter et. al.
    • Any book in the Sam's Teach Yourself XML series

    Many of these may be found in the library. Library systems usually offer free access to databases such as Safari Books Online, which carries complete versions of some XML texts.

  • slide 5 of 5


    • Tim Bray, who wrote the 1998 XML specifications and is of Sun Microsystems, has a blog where he expresses his dissatisfactions, hopes, and dreams for XML. Type "XML" into the search box to pull up relevant articles

XML for Everyone

This is a series of articles designed to teach basic XML to beginners. The prerequisite is a familiarity with HTML coding.
  1. An Introduction to XML - Part 1
  2. An Introduction to XML - Part 2