Tuesday, 18 November 2014

XML

Assalamualaikum my friends!



What is XML? Is it same with HTML?
No. It is not. XML stands for Extensible Markup Language. This language is much like HTML but its tags are not predefined, however XML is not replacement for HTML.

Differences between XML and HTML 

XML :
- Designed to transport and store data, with focus on what data is.
- It is about carrying information.
- All elements must be properly nested within each other:
<b><i>This text is bold and italic</i></b>
- The white-space in a document is not truncated

HTML :
- Designed to display data, with focus on how data looks
- It is about displaying information
- Improperly nested elements are allowed:
<b><i>This text is bold and italic</b></i>
- Truncates multiple white-space characters to one single white-space:
HTML: Hello my name is Tove
Output: Hello my name is Tove



There are three types of XML :


Number
Types of XML
1
Document
2
Tree
3
Table


XML document

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Now, we will explain briefly how to create XML document. Firstly, we put the XML declaration at the first line. 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 : <note>. The next four lines are the child elements of the root and the last line defines the end of the root element : </note>

XML tree

XML documents can form a tree structure. Here are the example of XML tree :



The image above represents one book in the XML below:

<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore> 

XML table


The image below represent the XML table :


I think that is all from us this time. If you want to know more details about this XML, you may watch this video : An Introduction to XML

Thanks for reading. Till we meet again :)


No comments:

Post a Comment