Introduction To XML - The Name Says It All…..EXtensible:
(Page 3 of 8 )
HTML has a fixed set of element types, for example TITLE, H1, H2, EM, BODY, P, HR, and so on. A valid HTML document must use these elements. It cannot invent its own. A browser vendor can of course add its own proprietary tags (for instance, Netscape's <BLINK> tag), but there is no standard way to introduce new element types. While this is not the case with XML. XML has the ability to define new elements, and furthermore, this can be done in the document itself. Thus, XML documents are in essence self-describing. Let's consider an example. Imagine that you are looking at an HTML document with the following table in it:
| Visual Basic Programming | BTech | Eduwardo Wancelloti | Naven Gokul Anna |
| Java Programming | EEE | Robert John
| Patricia Mary Sasi |
| ASP Programming | CSE | Devi Karun
| Susan Guna |
<table >
<tr>
<td> <i>Visual Basic Programming</i> </td>
<td> BTech</td>
<td> Eduwardo Wancelloti </td>
<td> Naven<br> Gokul <br> Anna </td>
</tr>
(and so on for each row)...
</table>
Although we as humans or programmers can make an educated guess, we really have no way of knowing what this data represents. Is "Visual Basic Programming" the name of a book? A course opted? Skill set required? It is impossible to say. And if it's a course (as appear to be), are there three named participants registered (Naven, Gokul, and Anna). Or just one named Naven Gokul Anna? XML fixes this. The corresponding information would be represented in XML like this:
<course>
<name> Java Programming </name>
<department> BTech </department>
<teacher> Eduwardo Wancelloti </teacher>
<student> Naven </student>
<student> Gokul </student>
<student> Anna </student>
</course>
The lesson here is tags can be anything you like, it is only how you use them that gives them meaning. Of course it is sensible to give meaningful names to start with. In the above example we have used XML to describe data, and we’ve used tag names that represent field names of the data. Thus in XML, information about the data structure can be preserved. It’s standard text, so can easily transfer from machine to machine. It’s not in proprietary format, so anyone can read it, and if the tags are named sensibly, the XML is self-describing. Furthermore, all information concerning presentation style has been removed from the document. We can say that this XML document evidently supports an element named "course," and the question you should be asking yourself is: But how am I supposed to know how to format this? (Notice that the HTML code contains a style directive for the text "Visual Basic Programming;" for example, the
element indicates italics.Next: Proof Is In The Output >>
More XML Articles
More By Gayathri Gokul