XML Introduction1
XML Introduction1
XML Introduction1
XML
Engr. Michael Marasigan Fernandez
Contents
List of topics to discuss in this session:
1. Static vs Dynamic Website
2. What is XML
3. Difference between XML and HTML
4. XML Does not use predefined tags
5. XML is Extensible
6. XML simplifies things
7. Define W3C and its importance
Assignment 1
2
STATIC vs
DYNAMIC
3
Static Website
is made up of webpages created using
HTML, CSS and Javascript (all examples
of web development languages).
4
Example of Static Website
1. resume websites
2. portfolio websites
3. brochure websites
5
Example of Static Website
6
Example of Static Website
https://www.redpaperplane.com/
7
Example of Static Website
8
Dynamic Web site
dynamic websites allow for the content of each
page to be delivered and displayed dynamically,
or on-the-fly, according to user behavior or from
user-generated content.
10
Example of Dynamic Website
11
Example of Dynamic Website
12
Example of Dynamic Website
13
Introduction
to XML
What is XML
- stands for eXtensible Markup Language
15
XML Example Coding
16
Difference Between XML and HTML
XML HTML
The full form is eXtensible Markup The full form is Hypertext Markup
Language Language
XML is dynamic because it is used in HTML is static because its main function
the transport of data is in the display of data
It is case-sensitive. The upper and
It is not case-sensitive. Upper and lower
lower case needs to be kept in mind
case are of not much importance in HTML
while coding
You can define tags as per your
It has its own pre-defined tags, and it is
requirement, but closing tags are
not necessary to have closing tags
mandatory
17
Difference Between XML and HTML
XML HTML
XML can preserve white spaces White spaces are not preserved in HTML
Any error in the code shall not give the Small errors in the coding can be ignored
final outcome and the outcome can be achieved
18
19
The XML Tree Structure
20
The XML Tree Structure
21
XML Tree Structure
Prolog
The XML prolog is optional. If it exists, it must
come first in the document.
root element
An XML tree starts at a root element
Parent element/s
branches from the root to parent
elements
Child element/s
All elements can have sub elements (child
elements)
- The terms parent, child, and sibling are used to describe the
relationships between elements.
- Parents have children. Children have parents. Siblings are
children on the same level (brothers and sisters).
- All elements can have text content (Harry Potter) and
attributes (category="cooking"). 22
XML Declaration
The XML document can optionally have an XML declaration. It is written as follows
Where version is the XML version and encoding specifies the character encoding used in the
document.
Whitespace characters like blanks, tabs and line-breaks between XML-elements and
between the XML-attributes will be ignored.
Some characters are reserved by the XML syntax itself. Hence, they cannot be used directly. To use
them, some replacement-entities are used, which are listed below −
Encoding UTF-8, UTF-16, ISO-10646-UCS-2, ISO- It defines the character encoding used in
10646-UCS-4, ISO-8859-1 to ISO-8859-9, the document. UTF-8 is the default
ISO-2022-JP, Shift_JIS, EUC-JP encoding used.
Syntax
Following is the syntax to write an XML element −
<element-name attribute1 attribute2> ....content </element-name>
where,
• element-name is the name of the element. The name its case in the start and end tags must match.
• attribute1, attribute2 are attributes of the element separated by white spaces. An attribute defines a
property of the element. It associates a name with a value, which is a string of characters. An attribute is
written as −
name = "value"
name is followed by an = sign and a string value inside double(" ") or single(' ') quotes.
XML - Elements
XML Elements Rules
• An element name can contain any alphanumeric characters. The only punctuation mark allowed in
names are the hyphen (-), under-score (_) and period (.).
• Names are case sensitive. For example, Address, address, and ADDRESS are different names.
• An element, which is a container, can contain text or elements as seen in the above example.
XML - Elements
XML Elements Rules
• An element name can contain any alphanumeric characters. The only punctuation mark allowed in
names are the hyphen (-), under-score (_) and period (.).
• Names are case sensitive. For example, Address, address, and ADDRESS are different names.
• An element, which is a container, can contain text or elements as seen in the above example.