Datasheet
❑ Opening and closing elements: All XML elements must have a closing element. Omitting a
closing element will cause an error. Exceptions to this rule is the XML definitional element at the
beginning of the document, declaring the version of XML in exceptions, and an optional style
sheet:
<root>
<branch_1>
<leaf_1>
</leaf_1>
</branch_1>
<branch_2>
</branch_2>
</root>
HTML tags do not always require a closing tag. Examine the first HTML code example in this chapter
in the section “Comparing HTML and XML.” The first paragraph does not have a
</P> paragraph end
tag. The second paragraph does have a
</P> paragraph eng tag. Some closing tags in HTML are
optional, meaning that a closing tag can be included or not.
❑ Case sensitive: XML elements are case sensitive. HTML tags are not case sensitive. The XML
element <root> in the previous example is completely different than the XML element <Root>
in the next example. The following example is completely different than the previous XML doc-
ument shown in the previous point. Even though all the elements are the same, their case is
different for the
<Root> and <BRANCH_1> elements:
<Root>
<BRANCH_1>
<leaf_1>
</leaf_1>
</BRANCH_1>
<branch_2>
</branch_2>
</Root>
HTML does not require proper nesting of elements, such as in this example:
<FONT COLOR=”red”><B><I>This is bold italic text in red</FONT></B></I>
XML on the other hand, produces an error using the preceding code. For example, in XML the
following code is invalid because
</tag2> should appear before </tag1>:
<tag1><tag2>some tags</tag1></tag2>
❑ Element attributes: Like HTML tags, XML elements can have attributes. An element attribute
refines the aspects of an element. Attributes and their values are called name-value pairs.
An XML element can have one or more name-value pairs, and the value must always be
quoted. HTML attribute values do not always have to be quoted, although it is advisable. In the
following XML document sample (the complete document is not shown here), populations for
continents (including the name of the continent) are contained as attributes of the
<continent>
element. In other words, the continent of Africa had a population of 748,927,000 people in 1998
(748 million people where the population in thousands is the total divided by 1,000, or 748,927).
14
Chapter 1
04_791202 ch01.qxp 10/6/06 10:59 AM Page 14