Beruflich Dokumente
Kultur Dokumente
Chapter 2
XML
105
1. Introduction
What is a structured document?
106
1. Introduction
This document is not well-structured
there is no defined rule
the order of items on the page
or the number of paragraphs
No structure rule is explicitly
associated with this document
It is easy to
forget one of the elements
or place them in the wrong order
2. XML
XML
Extensible Markup Language
has been developed by the XML Working Group
under the W3C since 1996
XML
is a generic markup language
It is primarily used to store / transfer data to fields arborescent
2. XML
Unlike HTML, which is considered
as a language-defined and fixed
with a limited number of tags
2. XML
XML is recognized by all current browsers
Example:
XML Copy (free)
EditiX XML (free)
Altova XMLSpy (fee required)
Oxygen XML (fee required)
110
3. Tag
XML documents contain
1. text that represents content (i.e., data), such as John,
2. elements that specify the documents structure, such as firstName.
3. Tag
An XML elements is delimit by
start tags and end tags
A start tag consists of the element name in angle brackets
e.g., <player> and <firstName>
An end tag consists of the element name preceded by a
forward slash (/) in angle brackets
e.g., </firstName> and </player>
<firstName>John</firstName>
Every XML document must have exactly
one element that contains all the other elements
root element
112
3. Tag
The name of the tag should describe the delimited data
113
114
116
Examples:
<?xml version="1.0"?>
<?xml version='1.0' encoding='iso-8859-1'?>
<?xml version="1.1" encoding="UTF-8" standalone="yes"?> 117
120
121
Parent of
122
Example:
Child of
123
Example:
Siblings
124
6. The attributes
The XML attributes allow
to store additional information about an item
without adding the text to the content of the element
this makes the document more confusing
to display or sort some elements
based on their attribute
125
6. The attributes
An attribute is a key-value pair
written under the form Key = "Value"
The syntax is:
<tag key="value">
Example:
Tag Name Attribute Name Attribute Value
Attribute
6. The attributes
Example:
<message priority ="low">
Attendance is mandatory in the course.
</message>
<message priority ="high">
Studying well for examination.
</message>
Tag: message
Attribute : priority
Value : low or high
We can display certain messages based on their priority
127
6. The attributes
same example without attributes:
<message>
<priority>low
<msg>
Attendance is mandatory in the course.
</msg>
</priority>
<priority> high
<msg>
Studying well for examination.
</msg>
</priority>
</message>
128
7. Special characters
The characters <, >, , , &
are reserved for XML
and can not be used directly
Characters Entity
< <
> >
"
'
& &
129
Valided Document :
well-formed document
respects the constraints structuring : includes a DTD or XML
Schema
130
131
132
133
134
135