Sunday, September 26, 2010

Difference between HTML and XML

You need to understand that you will not use XML for replacing HTML. Both XML and HTML have been designed for different goals which can be summarized as follows:


a. XML is designed specifically for describing and structuring the data where as HTML is used for formatting and displaying the data.

b. XML is focused on defining data with its attributes. It basically tells what data is all about. HTML is focused on presentation of data and is used to customize looks of data.

c. In case of HTML Document tags to be used and the structure of the documents are predefined. While using HTML you can only use tags which are pre-defined in the HTML standards. In case of XML you can define your own tags and develop your own document structure.

d. An XML document is saved with an extension .XML whereas an HTML document is saved as .HTML.

E.g. The following example is an e-mail from Ram to Shyam stored as XML

< email >
< to > Ram </to >
< from > Shyam < /from >
< subject > Hi how are you? </subject >
< content > Let’s go for a New Year party </content >
< /email >

In above example e-mail has been stored using XML markup language. You can see that own tags have been created to store the names of sender and receiver. Similarly different tags have been created to store the subject and content of the web page.

No comments:

Post a Comment