Wednesday, November 06, 2013

All about XML

What is XML?

I've published several posts on HTML. But this is my first post on XML that stands for eXensible Markup Language. Before starting the main discussion, I'd like to inform you that I've collected information about XML from w3schools. I was just surfing that site and suddenly my eyes go to the XML tutorials. Then I decided to write something on XML.

In fact, today's post is a knowledge base article. From this post, you will know about - what is XML. This post will not teach you how to prepare XML files. So, don't be confused.

Okay let's start - XML doesn't do anything! Confused? But there is no way to be confused actually when you will know that XML is nothing except some texts stored in tags.

  • XML - EXtensible Markup Language.

  • It's used to store and transport data.

  • Unlike HTML, XML is only used to store and transport data, not to display.

  • Unlike HTML, here you can define your own tags.

  • XML is simply a complement to HTML.

How Does XML Differ from HTML?

A Good question to reply. When you browse a site through internet, you just see structured texts, images, pages etc. You never see the codes behind those beautiful sites. But your browser has to interpret those pages using HTML. Any browser uses HTML to display websites.

HTML is used to display data. In contrast, XML is used to store and transport data. You can define your own tags in XML. But you can't do the same thing in HTML. Because HTML doesn't allow you to create something by yourself. It has some specific rules.
If you wanna learn about XML, you should have a basic knowledge in HTML and JavaScript.

A Little Example:

The following example may provide you a true understanding of an XML document. This is a piece of message. It has a sender, a receiver, a subject and a body. But the information is only wrapped in tags. You must use a media to send the information somewhere.

<body>Never forget to inform me about AdSense Letter</body>

The message above is absolutely self descriptive in that sense that some of the tags are invented by myself! The tags - <Message>, <Subject> are my own creation! In XML, you're allowed to create your own tags. Surprisingly, XML language has NO predefined tags!  XML allows author to define his/ her own tags and document structure.

Where you are, You with the XML!

XML became a W3C Recommendation on February 10, 1998. It is as important as HTML. XML is the most common tool for the transmission of data among all sorts of applications.  

Stay with Marks PC Solution to get more interesting IT topics!

1 comment:

  1. Good to see my name here!

    But the title says, all about XML. Well, to be honest, the post does not explain all the things about xml. It just defines it. XML has many rules. In fact, it is strictly structured. Even a single disposition of a character can break the whole XML code. There are 2 important rules for XML which you should mention.

    1. Every tag that starts must have an ending tag. (<tag></tag>) But if it doesn't contain anything inside it, it can go like this: <tag /> (without the ending tag.)

    2. Every attribute must have values enclosed with double quotes. Early HTML standards did not specify this. But XHTML (or HTML with XML standards) takes this rule seriously.
    So, <input type="checkbox" checked > is invalid.
    But, <input type="checkbox" checked="checked" /> is valid.

    These 2 rules are the gist of XHTML.

    You are right that XML does not do anything by itself. It is just data. The reason behind inventing this complex data structure is that it is ideal for storing hierarchical data. For example,


    <parent name="Shameem" role="Father" />
    <parent name="Khaleda" role="Mother" />

    <child name="Khalid" role="Son" />
    <child name="Tarik" role="Son" />
    <child name="Tanvir" role="Son" />
    <child name="Adnan" role="Son" />

    Here you can see that the family structure has been presented in a hierarchical manner. The tags are there. So if you want to add another parent, for example, a grand parent, it is easier. And from the single code you can understand the hierarchical relation among the data. Examples would make it clearer my friend.