XML is conceived of as a way to extend the power of online delivery of information. Although both XMLand HTML are derived from SGML (Standard Generalized Markup Language), there are important differences between the two markup languages. For one, HTML provides a fixed set of tags, while XMLenables users to define the tags that they need. For another, HTML primarily describes how information should be rendered; it does not lay out what the information is or how it is structured.HTML is about information display or presentation, whereas XML concentrates mainly on structure of the information.
In contrast, XML provides information about structure and syntax. (Directions for formatting are included in a separate stylesheet attached to the document.) Whereas HTML is meant only to be used for presentation of documents in Web browsers, XML has wider applications. Not only can it be used for the web, but also as a storage format for word processors, as a data interchange format, and as a preservation format that is readable by humans users.
Let’s make this more concrete by looking at an example, here a tutorial record:
HTML Version
XYZ Kumar
Anatomy of XML
XML guide for Developers Pvt. Ltd.
The HTML code looks like this:
<B>XYZ Kumar</B><BR>
<I> Anatomy of XML </I> <BR>
XML guide for Developers <BR>
<b> Company :</b>
XML Version
In contrast, XML enables you to describe the specific components of a document or database
<?xml version=”1.0″ encoding=”ISO-8859-1”?>
XYZ Kumar</author>
<title>Anatomy of XML</title>
<subtitle>XML guide for Developers </subtitle>
<company> Pvt. Ltd.</company>
To achieve the same online presentation, the XML document would be associated with an XSL stylesheet like the following:
<?xml version=”1.0″?>
<xsl:stylesheet xmlns:xsl=””>
<xsl:template match=”tutorial”>
<xsl:template match=”author”>
<xsl:template match=”title”>
<xsl:template match=”subtitle”>
<xsl:template match=”company”>
The Main Difference Between XML and HTML
XML is not a replacement for HTML, it is a complement to XML.
Both, XML and HTML were designed with different goals:
XML was designed to describe data and to focus on what data is. That is, structure of data.
HTML was designed to display data and to focus on how data looks. That is, presentation of data.
HTML is about presenting information, while XML is about describing information.
XML was designed to carry data and HTML was designed to display the on user’s browser window. HTML does not know anything about data, and its structure and XML does not know anything about how to present the data.