What is XML?
XML was designed to transport and store data while HTML was designed to display data.What is XML?
The Difference Between XML and HTML
| XML | HTML |
|---|---|
| to transport and store data, with focus on what data is | to display data, with focus on how data looks |
| carrying information | displaying information |
How to Use XML?
What is an 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>
In the example above,
<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.
If we try to tabulate the example, below is the result:
BOOKSTORE
| Book Category | Title | Author | Year | Price |
|---|---|---|---|---|
| CHILDREN | Harry Potter | J K. Rowling | 2005 | 29.99 |
| WEB | Learning XML | Erik T. Ray | 2003 | 39.95 |
XML Tree
An Example
XML Document
XML documents
use a self-describing and simple syntax:
<?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>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<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"):
<note>
The next 4 lines describe 4 child elements of the root (to,
from, heading, and body):
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
And finally the last line defines the end of the root
element:
</note>
You can assume, from this example, that the XML document
contains a note to Tove from Jani.
Don't you
agree that XML is pretty self-descriptive?
XML
Documents Form a Tree Structure
XML
documents must contain a root element. This element is "the parent"
of all other elements.
The elements
in an XML document form a document tree. The tree starts at the root and
branches to the lowest level of the tree.
All elements
can have sub elements (child elements):
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
<child>
<subchild>.....</subchild>
</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).
All elements
can have text content and attributes (just like in HTML).
Example:
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>
<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>
The root element in the example is <bookstore>. All
<book> elements in the document are contained within <bookstore>.
The
<book> element has 4 children: <title>,< author>,
<year>, <price>.
We are currently living in such a vast IT developed world. Talking about the history of internet though, people might not be very interested, but just for the purpose of getting knowledge, we are about to simplify the history of internet inventions through out it centuries.
the timeline is summerized as shown in the figure below:
Well.. the fact we shared here is somehow simple, for further and deeper information please refer to this web site boring timeline (may be) ..
And finally," History is where we began".






No comments:
Post a Comment