welcome peeps !

welcome peeps !

Sunday, 3 November 2013

XML

All 'bout XML

Assalamualaikum...hey, we meet again (^.^)V How are u?




          
         Today we are going to learn about XML. You really wondering what does XML stands for right? Ok, XML stands for Extensible Markup Language which was designed solely to carry data. Wait a minute, don't get confuse between HTML and XML because HTML is all about displaying the data. In contrast to XML which is to transport and store the data.

          Actually, we already been using XML since its creation. This is because it is the common tool for data transmission between applications and becoming more and more popular from the perspective of data storage and describing data. How XML separates data from HTML?



  • If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML each time the data changes.
  • With XML, data can be stored in separate XML files
  • This way you can concentrate on using HTML for layout and display, and be sure that changes in the underlying data will not require any changes to the HTML
  • With a few lines of JavaScript, you can read an external XML file and update the data content of your HTML

  •        As example here is a note to Terry from John
     <note>
     <to>Terry</to>
     <from>John</from>
     <heading>Reminder</heading>
     <body>Call me before 6 p.m.!</body>
     </note>

    1) XML Syntax Rules:



  • All XML Elements Must Have a Closing Tag
  • In HTML, you will often see elements that don't have a closing tag:
  •          <p>This is a paragraph<p>This is another paragraph
  • In XML, it is illegal to omit the closing tag. All elements must have a closing tag: 
  •          <p>This is a paragraph</p><p>This is another paragraph</p>

    2) XML Tags are Case Sensitive:



  • XML elements are defined using XML tags
  • With XML, 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>
             <message>This is correct</message>

    3) XML Elements Must be Properly Nested

     Correct:  <b><i>This text is bold and italic</b></i
         
      Incorrect:  <b><i>This text is bold and italic</i></b>

    4) XML Documents Must Have a Root Element

    XML documents must contain one element that is theparentof all other elements
              
               <root>
                  <child>
                    <subchild>.....</subchild>
                  </child>
               </root>

    5) XML Attribute Values Must be Quoted

    Correct:  
                     <note date=12/11/2007>
                       <to>Terry</to>
                       <from>John</from>
                     </note>

    Incorrect:
                    <note date="12/11/2007">
                      <to>Terry</to>
                      <from>John</from>
                    </note>

    As conclusion, there are 2 obvious differences between XML and HTML:

          
    XML HTML
    Designed to transport and store data, with focus on what data is Designed to display data, with focus on how data looks
    Carry information Display information

    For more info, visit this site.