List of Articles

Why XML (Extensible Markup Language)

We know two markup languages now, one is HTML and other is WML. HTML is used for browsers and WML is used for PDA’s. We also have lots of other types of Markup languages like HDML etc for specific handsets. Now with all these markup languages why is there a need for XML? And, why it has so much of importance. The first striking feature of XML is, it keeps the information about the data. In other Markup languages more importance is always given to the way it shows information. But in case of XML data is most important. XML doesn’t give us any readymade tags to work on. So we can define our own tags and specify how the information should be maintained.

So if we look at a simple html file, which is having information about a simple employee structure.

<HTML>

<HEAD><TITLE>EMPLOYEE</TITLE></HEAD>

<BODY>

<H1>EMPLOYEE INFORMATION</H1>

<H3>EMPNO : 1000<BR>

NAME : SAGAR KULKARNI<BR>

SALARY : 9,999<BR>

QUALIFICATION : BE (MECH) <BR>

</H3>

</BODY>

</HTML>

Now this file serves the basic purpose of displaying employee structure. We can use many features of html to articulate the display. When I have the task for 50 people I can repeat the same structure 50 times. And here we start getting new requirements. When number of records increases, then we want to either arrange this information in some different style or have a query based on the data, which we have. HTML is showing me the information but can’t understand the information. In the above HTML code, if we want to display all employees having salary more than 10,000, we can not run this query. Retrieval of data with specific criteria is not possible in HTML. This is a major drawback of HTML, which is overcome in XML

In practical scenario, the situation we described above is very common.

Other major requirement of having and defining a structured approach to data is also arising because of lots of proprietary ways of keeping data. So in some cases data is stored in flat files, in a DBMS, some data is ORDBMS and every software has its own ways of storing the data. If we want to generate some reports on information from these three sources then it becomes time consuming and difficult to extract and collect information. So in many cases it happens that even if the data is available, it can not be used to produce MIS reports easily.

XML is an emerging solution to all these problems. It has all customized tags to keep information. It can be used as a mediator to exchange data between different formats. Since the data is kept with user defined tags, we can also have queries, which can extract information from XML file. So a simple XML file for employee information will look like

<empinfo>

<empno>1000</empno>

<name>SAGAR KULKARNI</name>

<salary>9,999</salary>

<qualification>BE (MECH)</qualification>

</empinfo>

Where empinfo, empno, name etc are all user defined tags.

We are not having any display related tags in above code. XML doesn’t give you any such tags. That can be done using CSS, XSL etc. That we will discuss in the next article.

How this code will be displayed depends currently on browser. If we look at this file in IE5 it will be displayed like a tree and it will give collapsible notes also. IE 5 can display this file because it has a in built parser to parse the XML file. Many parsers are available from different vendors.

What document we have created above is called as Well Formed XML document. It indicates that the document is having proper starting and ending tags and hierarchy is maintained. But in live applications we will have to have more specifications on how the document should be, what tags are mandatory, in what sequence etc. And all these will be done by Document Type Definations. We will look at DTDs in the next article.

The author, Mrs. Vaishali Tapaswi is Director, Fands Infotrainers. For additional Information on XML she can be reached at vaishali@fandsindia.com