Thursday, September 5, 2013

XML - (A) Introduction


XML Introduction

XML stands for eXtensible Markup Language.

XML is designed to transport and store data. 
HTML was designed to display data. 

* XML tags are not predefined. You must define your own tags . ( ex : <to>, <from> )
* XML is designed to be self-descriptive
* XML is a W3C Recommendation 

* XML was created to structure, store, and transport information. It is just information wrapped in tags.
<note>
     <to>Sanjeeva</to>
     <from>Sandamali</from>
     <message>Happy Birthday</message>
</note>

* XML Separates Data from HTML
XML data is stored in plain text format. This provides a independent way of storing data. This makes it much easier to create data that can be shared by different applications.
      Due to this;
            - XML Simplifies Data Sharing
            - XML Simplifies Data Transport
            - XML Simplifies Platform Changes
            - XML Makes Your Data More Available
            - XML is Used to Create New Internet Languages ( XHTML, WSDL, WAP, WML, RSS, etc. )

XML Tree Structure

<root>
           <child></child>
           <child>
                      <sub-child></sub-child>
           </child>
</root>

* The terms parent, child, and sibling are used to describe the relationships between elements.
* Parent elements have children.
* Children on the same level are called siblings (brothers or sisters).

Basics :

* XML Element Must Have a Closing Tag.  
          <message></message>

* XML tags are case sensitive. 
          The tag <Letter> is different from the tag <letter>.

* Opening and closing tags must be written with the same case. 
           <Message>This is incorrect</message>

* XML Elements Must be Properly Nested  
           <name><firstname>Sanjeeva</firstname></name>

XML Element -

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

An element can contain:
         - other elements
         - text
         - attributes
         - or a mix of all of the above...

<bookstore>
       <book category="CHILDREN">
               <title>Harry Potter</title>
               <author>J K. Rowling</author>
               <year>2005</year>
               <price>29.99</price>
       </book>
       <book category="WEB">
               <title>Learning XML</title>
               <author>Erik T. Ray</author>
               <year>2003</year>
               <price>39.95</price>
       </book>
</bookstore>

<bookstore> and <book> have element contents, because they contain other elements.

<book> also has an attribute (category="CHILDREN").

<title>, <author>, <year>, and <price> have text content because they contain text.

Reference : http://www.w3schools.com