Itec102 Midterm L1
Itec102 Midterm L1
XML
ITEC102 – Integrative Programming and Technologies
Introduction to XML
Why Study XML?
➢ XML plays an important role in many different IT
systems.
➢ XML is often used for distributing data over the
Internet.
➢ It is important (for all types of software
✓ What is XML?
✓ How does XML work?
✓ How can I use XML?
✓ What can I use XML for?
Introduction to XML
What is XML?
Because of this, with XML, there is a full separation between data and
presentation.
When displaying data in HTML, you should not have to edit the HTML file
when the data changes.
With a few lines of JavaScript code, you can read an XML file and update
the data content of any HTML page.
<?xml version="1.0" encoding="UTF-8"?>
<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">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
</bookstore>
Transaction Data
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
XML Tree Structure
XML Syntax
Rules
The syntax rules of
XML are very simple
and logical. The rules
are easy to learn, and
easy to use.
XML Documents Must Have a Root
Element
XML documents must
contain
one root element that
is the parent of all
other elements:
The XML Prolog
This line is called the
XML prolog:
The XML prolog is optional. If it
exists, it must come first in the
document.
XML documents can contain
international characters, like
Norwegian øæå or French êèé.
To avoid errors, you should specify
the encoding used, or save your
XML files as UTF-8.
UTF-8 is the default character
encoding for XML documents.
UTF-8 is also the default encoding
for HTML5, CSS, JavaScript, PHP,
and SQL.
➢ All XML Elements Must
Have a Closing Tag