Sunday, May 12, 2013

Similarities and differences between HTML and XML

The Difference Between XML and HTML

The most salient difference between HTML and XML is that HTML describes presentation and XML describes content. An HTML document rendered in a web browser is human readable. XML is aimed toward being both human and machine readable.
Consider the following HTML.

<html>
<head><title>Books</title><head>

<body>

<h2>Books</h2>
<hr>

<em>Sense and Sensibility</em>, <b>Jane Austen</b>, 1811<br>
<em>Pride and Prejudice</em>, <b>Jane Austen</b>, 1813<br>
<em>Alice in Wonderland</em>, <b>Lewis Carroll</b>, 1866<br>
<em>Through the Looking Glass<</em>, <b>Lewis Carroll</b>, 1872<br> 

</body>
</html>

The previous HTML is rendered in a browser as follows.


The HTML above describes how bibliography information is to be presented and formatted for a human to view in a web browser. Knowing that Sense and Sensibility is enclosed in italic tags does not however help a program determine that it is the title of a book. XML attempts to describe web data to address this void.
The following is XML describing the contents of the books HTML page above.


<books>
   <book>
      <title>Sense and Sensibility</title>
      <author>Jane Austen</author>
      <year>1811</year>
   </book>

   <book>
      <title>Pride and Prejudice</title>
      <author>Jane Austen</author>
      <year>1813</year>
   </book>

   <book>
      <title>Alice in Wonderland</title>
      <author>Lewis Carroll</author>
      <year>1866</year>
   </book>

   <book>
      <title>Through the Looking Glass</title>
      <author>Lewis Carroll</author>
      <year>1872</year>
   </book>
</books>

A program parsing this data can take advantage of the fact that all book titles are enclosed in <title> tags. Where would such a program find such information? An XML document may contain an optional description of its grammar. A grammar describes which tags are used in the XML document and how such tags can be nested. A grammar is a schema or road map for the XML document. Originally an XML grammar was specified in aDTD (Document Type Definition). A newer standard however, XSchema (XML Schema) has been adopted. XSchema addresses some of the limitations of DTDs.
As can be seen above, XML does not contain any information indicating how the document should be rendered in a browser. Therefore, XML factors data from presentation. The beauty of this feature is that the same data can be presented in a variety of ways without having to replicate any data (e.g., consider making book titles bold and authors italic).
XML is not a replacement for HTML.
XML and HTML were designed with different goals:
  • XML was designed to transport and store data, with focus on what data is
  • HTML was designed to display data, with focus on how data looks
HTML is about displaying information, while XML is about carrying information.

XML is Not a Replacement for HTML

XML is a complement to HTML.
It is important to understand that XML is not a replacement for HTML. In most web applications, XML is used to transport data, while HTML is used to format and display the data.
My best description of XML is this:
XML is a software- and hardware-independent tool for carrying information.



Opinion On The Future of XML

XML is good in the future as nowadays web applications are being used widely in the whole world. there is also some facts that i read been discussed for a new version of XML which is the XML 2.0. This version has been proposed to contain the following characteristics:

1)Elimination of DTDS.
2)Integration of namespace.
3)XML Base and XML Information Set into the base standard.


If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML each time the data changes.

With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS for display and layout, and be sure that changes in the underlying data will not require any changes to the HTML.


The future of XML is very bright because as we depend more on machines, these machines will need some sort of proper procedure or syntax to analyze the information that we provide it. This is where XML will come into play where data and information can be transported and understood by all machines. XML will be the universal language of machines.