Struggling with XML? Can't figure out the difference between an entity and a namespace? Fear not - our XML series has all the answers. This introductory article discusses the origins and design goals of XML, the basic rules of XML markup, and how to use elements and attributes in an XML document.
The document prolog is followed by a series of "elements". An element, which is the basic unit of XML, consists of textual content (or "character data"), enhanced with descriptive tags (or "markup"). The boundaries of an element are defined by start and end tags, and may contain additional descriptive "attributes".
XML also allows for so-called empty elements - essentially, elements which have
no content and therefore do not require a closing tag. Such elements are closed by adding a slash (/) to the end of their opening tag. For example,
<rule>Every sentence ends with a <period /></rule>
An element name must begin with a letter, optionally followed by more letters
and numbers. For example,
<popeye>
<book>
<INCOME>
are all valid element names.
Element names are case sensitive - so
<me>
is different from
<Me>
or
<ME>
An element may contain only text,
<step>Garnish with lemon and chopped onions</step>
or a combination of text and other elements.
<sentence>The red <animal>wolf</animal> jumped over the blue
<vegetable>aubergine</vegetable></sentence>
In order to be well-formed, an XML document must contain at least one non-empty
element. This outermost element is called the "root element" and, in turn, may contain other elements, nested in a hierarchical manner. In the first example above, the root element would be <review>...</review>.
This article copyright Melonfire 2001. All rights reserved.