Saturday, January 9, 2010

XML

Categories: ,

XML can store data, but it is not a database. XML can serialize objects, but an XML document is not an object. Web pages can be written in XML, but XML is not HTML. Functional (and other) programming languages can be written in XML, but XML is not a programming language. Books are written in XML, but that doesn't make XML desktop publishing software.


XML Makes Your Data More Available

Since XML is independent of hardware, software and application, XML can make your data more available and useful.
Different applications can access your data, not only in HTML pages, but also from XML data sources.
With XML, your data can be available to all kinds of "reading machines" (Handheld computers, voice machines, news feeds, etc), and make it more available for blind people, or people with other disabilities.

XML is Used to Create New Internet Languages

A lot of new Internet languages are created with XML.
Here are some examples:
  • XHTML the latest version of HTML 
  • WSDL for describing available web services
  • WAP and WML as markup languages for handheld devices
  • RSS languages for news feeds
  • RDF and OWL for describing resources and ontology
  • SMIL for describing multimedia for the web  

    An Example XML Document

    XML documents use a self-describing and simple syntax:

    <note>
        <to>Toveto>
        <from>Janifrom>
        <heading>Reminderheading>
        <body>Don't forget me this weekend!body>
    note>
    The first line is the XML declaration. It defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/West European character set).
    The next line describes the root element of the document (like saying: "this document is a note"):
    The next 4 lines describe 4 child elements of the root (to, from, heading, and body):
    Tove
    Jani
    Reminder
    Don't forget me this weekend!
    And finally the last line defines the end of the root element:


    All elements can have sub elements (child elements):

     
        .....
     



    Example:

    DOM node tree The image above represents one book in the XML below:

     
       
        Giada De Laurentiis
        2005
        30.00
     

     
       
        J K. Rowling
        2005
        29.99
     

     
       
        Erik T. Ray
        2003
        39.95
     



    All elements must have a closing tag:
    This is a paragraph

    This is another paragraph


    XML Tags are Case Sensitive

    XML Elements Must be Properly Nested

    This text is bold and italic

    XML Documents Must Have a Root Element

    XML documents must contain one element that is the parent of all other elements. This element is called the root element.

     
        .....
     


    XML Attribute Values Must be Quoted

    This will generate an XML error:
    if salary < 1000 then
    To avoid this error, replace the "<" character with an entity reference:
    if salary < 1000 then
    There are 5 predefined entity references in XML:
    < < less than
    > > greater than
    & & ampersand 
    ' ' apostrophe
    " " quotation mark
    Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal, but it is a good habit to replace it.





    White-space is Preserved in XML

    HTML truncates multiple white-space characters to one single white-space:
    HTML: Hello           my name is Tove
    Output: Hello my name is Tove.
    With XML, the white-space in a document is not truncated.

    XML Stores New Line as LF


Spread The Love, Share Our Article

Related Posts

No Response to "XML"

Post a Comment