Monday, 5 March 2012

Introduction to XML


Hi all through this post I am trying to give an Introduction to XML as far as I learnt.

When I started learning the XML the first question that always which gets into my mind is as to what exactly XML is:

What is XML ?
Extensible Markup Language
XML is text based markup language.
XML is more than HTML because HTML only deals with presentation and carries no information about the data itself.
XML is designed to be self-descriptive
XML is a platform and application independent 

The other information regarding XML is given below:

Advantages of XML
    
 Readability 
   
XML document is plain text and human readable, To edit/view XML documents any simple text editor will suffice .
 Hierarchical 
   
XML document has a tree structure which is powerful enough to express complex data and simple enough to understand
 Language Independent 
   
XML documents are language neutral.For e.g. a Java program can generate a XML which can be parsed by a program written in C++ or Perl.
 OS Independent 
   
XML files are Operating System independent.
The Difference Between XML and HTML
XML is not a replacement for HTML.
XML and HTML were designed with different goals:
  • XML was designed to transport and store data, with focus on what data is
  • HTML was designed to display data, with focus on how data looks
HTML is about displaying information, while XML is about carrying information.

XML Syntax Rules

ü  All XML Elements Must Have a Closing Tag
                        <p>This is a paragraph</p>

ü  XML Tags are Case Sensitive
       --Opening and closing tags must be written with the same case:        

                        <Message>This is incorrect</message>
                        <message>This is correct</message>

ü  XML Elements Must be Properly Nested

                         <b><i>This text is bold and italic</i></b>
        "Properly nested" simply means that since the <i> element is opened inside the <b> element, it must be closed inside the <b> element

ü  XML Documents Must Have a Root Element
            <root>
                  <child>
                         <subchild>.....</subchild>
                  </child>
          </root>

ü  XML Attribute Values Must be Quoted
          <note date="12/11/2007">
               <to>Tove</to>
               <from>Jani</from>
          </note>

Let me make you to travel through an example which gives you an exact picture of an XML:
XML example


No comments:

Post a Comment