Monday, April 5, 2010

What is XML

XML is a strong and flexible language.

As soon as we read the word ‘language’, most of the persons, new to XML, consider it as some programming language and start wondering what all we can create using XML language.

But Friends, XML is not a programming language but it is a language. Language means a way of communication which can communicate the intended message to the other partners, which can make them understand what we want to say. It is like any other language which used to have a grammar to write and read the messages.

XML works in similar fashion. It does have its own protocol i.e. defined set of rules (grammar) that how one should write and read the messages using XML. 


Please refer to http://www.w3.org/XML/ for details.

XML message is a text message having some fixed notations and standards. And the good thing is that there are many softwares in almost all the languages which are able to parse and decode the XML messages and hence facilitate to retrieve the contents from the message. XML message does not have any meaning in itself, but the receiver can use the content retrieved from XML message for any purpose based on the fixed protocol between sender and receiver. So sender and receiver can define any new protocol and then can communicate using this protocol by writing the message in XML following the fixed protocol. This is the reason that XML is called extensible language, as you see that user can define any new standard easily.

So how does receiver understand that what senders want to say?

At receiver end, the software parser parses the XML message, ensure that it is conforming to the XML standards and hand over the message contents to the receiver. Not it is the receiver who will interpret the message contents as per the set protocol between sender and receiver. For example

XML Message is:


<books>
<book>
<name  value=”ABC”/>
<price value=”500”/>
<description>
It is sample description
</description>
        </book>
<book>
<name  value=”DEF”/>
<price value=”1200”/>
<description>
It is sample description for second book
</description>
       </book>
</books>

Now parse will parse the message and will hand over the contents to the receiver. Receiver can interpret the meaning of message as
  • There are two books
  • First book
    • Name is ABC
    • Price is 500
    • Description is ‘It is sample description’
  • Second book
    • Name is DEF
    • Price is 1200
    • Description is ‘It is sample description for second book’

Now receiver can use this information for any purpose, like he can show the information on a web page, or he can update the information in his inventory system.

How is XML platform independent?

As explained above, XML is a text message with some standard grammar. Now every platform can have the tools which can parse a text file or text contents following some standard. So it makes it feasible to parse and understand the contents written using XML on any platform or in any language. It just needs a parser software on the specific platform in required programming language, which can read the XML message and can retrieve the contents. So over the wire, we are transferring the text contents, it is just the standard format of XML which enable to deduce any meaning from the content.

How to validate the XML?

There are two difference approaches used to validate the XML.

  • DTD – It is a definition of protocol for XML message with some specific format in text file. It explains that what should be written in XML document and what should not be.

  • XML Schema – It is again definition of protocol for XML message but used to written using XML standard. This is the reason that it is more popular than DTD, as it is more readable and extensible.

No comments:

Post a Comment