O'Reilly logo

XML Pocket Reference, Second Edition by Michel Casabianca, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XML Terminology

Before we move further, we need to standardize some terminology. An XML document consists of one or more elements. An element is marked with the following form:

<Body>
This is text formatted according to the Body element
</Body>.

This element consists of two tags: an opening tag, which places the name of the element between a less-than sign (<) and a greater-than sign (>), and a closing tag, which is identical except for the forward slash (/) that appears before the element name. Like HTML, the text between the opening and closing tags is considered part of the element and is processed according to the element’s rules.

Elements can have attributes applied, such as the following:

<Price currency="Euro">25.43</Price>

Here, the attribute is specified inside of the opening tag and is called currency. It is given a value of Euro, which is placed inside quotation marks. Attributes are often used to further refine or modify the default meaning of an element.

In addition to the standard elements, XML also supports empty elements. An empty element has no text between the opening and closing tags. Hence, both tags can (optionally) be combined by placing a forward slash before the closing marker. For example, these elements are identical:

<Picture src="blueball.gif"></Picture>
<Picture src="blueball.gif"/>

Empty elements are often used to add nontextual content to a document or provide additional information to the application that parses the XML. Note that while the closing slash ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required