Basic XML Syntax and Well-Formedness

by K. Yue
August 2002
copyright 2002

1. Introduction

2. Elements and Attributes

Example:

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

Example:

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

Example:

HTML: the following file is OK (missing <html> element):
<head>…</head><body>…</body>
XML: must has only one root element.

Example:

HTML: an empty element simply has no end tag:<br>, <hr>, etc.
XML: must use <br/> or <br></br>.

Example:

HTML: <IMG SRC=abc.gif> OK
XML: must be <img src="abc.gif"/> or <img src='abc.gif'/>

3. XML Entities

Example:

If the named entity "yue" is defined as "Kwok-Bun Yue" in the DTD used by the XML document, then every occurrence of "&yue;" within the XML document will be replaced by "Kwok-Bun Yue"

4. Miscellaneous Markups

4.1 Comments

4.2 Strings and Characters

Example:

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

4.3 CDATA Sections

Example:

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

5. Well-Formedness



Dr. Kwok-Bun Yue
Professor, Computer Science and Computer Information Systems
Chair, Division of Computing and Mathematics
University of Houston-Clear Lake
2700 Bay Area Boulevard
Houston, TX 77058
Yue's Home  Yue's home page     Yue's email  yue@uhcl.edu     phone  281-283-3864