An Introduction to XML
K. Yue copyright 2000
Created: November 22, 2000

Introduction

Example:

<?xml version="1.0"?>
<memo priority="very high">
<from>Bun Yue</from>
<to>Everybody</to>
<body>
Hello, welcome!
</body>
</memo>

Comparing XML and HTML

XML HTML
A meta-language for defining markup languages A markup language
For data only For data and display
Describe application structures; no intrinsic display instruction. Describe display instructions.
Users to define tags Fixed number of tags
Web and non-Web Web only
Used in both client-side and server-side Used in clients (browsers)

Problems with HTML

Example:

In HTML:

<h2>Bun Yue</h2>
<h2>Introduction to XML</h2>

It is difficult for the HTML browser to get the meaning of the data "Bun Yue" and "Introduction to XML".

XML advantages

XML provides semantic meaning.

Example:

<author>Bun Yue</author>
<booktitle>Introduction to XML</booktitle>

Core XML Technologies

XML Syntax

Example:

HTML: <IMG...>…</img> ok.
XML/WML: must be <img…>…</img>.

Example:

HTML: <p>first<p>second ok.
XML/WML: must be <p>first</p><p>second</p>.

Example:

HTML: the following file is ok:
<head>…</head><body>…</body>
XML: must has only one root element.

Example:

HTML: an empty element simply has no end tag:<br><hr>.
XML/WML: <br/> or <br></br>.

Example:

HTML: <IMG SRC=abc.gif> ok.
XML/WML: must be <img src="abc.gif"/>.

XML Entities

Strings and Characters

String literals are enclosed by quotes. They are used as attribute values.

Example:

"I'm fine."
'The quotes: "I&apos;m fine." is for you'
"Quotes using entity references: &quot;."

CDATA

Example:

<code>
<![CDATA[
<%
Response.write "<td>hi</td>"
%>
]]>
</code>

Well-Formedness