Saturday 18 May 2013

HTML and XML

     This article talks about two of the most popular markup languages of IT world, HTML (Hyper Text Markup Language) and XML (eXtensible Markup Language)We are going to have a look at their differences ,similarities and the problems that they try to solve. If you are looking for a complete tutorial, go to W3C : ).

    Even if you are not a web developer you must have come across HTML during your college days and XML is something that is a hot topic in the world of web services (we will see that later). Now let us try to define some terms.

markup language is used to embed the real data with tags. The tags are nothing but metadata (data about data) that may contain information about the presentation or meaning of data.  

Hypertext document contains links to other information.

Extensibility, in the domain of Information Technology , is a property that allows the end users or developers of a system to add more to its capabilities.

     HTML finds its use in the development of  web pages. HTML tells the web browser how the information contained in the page is to be displayed to the end user. Almost all the static content that you see on a web page is generated with help of HTML. Other technologies like JavaScript and flash take care of the dynamic content. On the other hand XML is a cross platform hardware/software independent standard which can be used as a data carrier across two different systems or it can be used as a way to store data. So basically HTML was designed to focus on the presentation of data and XML was designed to describe what data is and to be used as a means of data exchange. One more important point to note is that in HTML tags are already defined but in XML the developer has to define custom tags according to his requirements (extensibility). We can also look at XML as a framework that allows us to define a new markup language.One more thing to keep in mind is that HTML is case-insensitive but XML is case sensitive. Now let us take a few examples.

HTML example:


<h1>Seiko wrist watch</h1>
<p>The price is 100000 rs.</p>

XML example:

<product>
<item>Seiko wrist watch</item>
<cost>100000</cost> 
</product> 


      The examples are by no means ideal. The purpose is to show how the same data may be represented in both the languages. The HTML tags take care of the presentation of data and in the XML example the tags are describing the data itself. XML provides a very powerful way of storing data in an application independent format.Many standard software can generate their output in XML format which can be read by a different application. 


    When we communicate with a web application using a browser the HTML files are sent over HTTP (carrier) to the browser which renders the data as described by HTML. Now let us try to imagine a case where two web applications need to communicate with each other (e.g. while shopping online the vendor talks to the payment gateway then the gateway talks to your bank). Again we may use HTTP as the carrier but what about HTML? Can a machine understand bold text or the plain English used to convey data to humans? The answer is no and this is where XML comes in to picture.In simple words we can say that web services are nothing but web apps talking to each other. XML messages are sent over HTTP which are understood by applications using predefined rules. The involved applications may have been developed using different web development platforms but they all understand XML. Of course XML has competitors in the domain of web services but that goes beyond the scope of this article.

      Basically web applications are designed to be consumed by humans and and web services are designed to be consumed by other applications.

No comments:

Post a Comment