Like HTML, XML marks the beginning and ends of sections of text using tags:
<sentence>This is a sentence.</sentence>
In this example, "sentence" is what XML calls an element. Elements can be considered the nouns of XML. The sentence element is tagged with <..> at the beginning and ends with </..>.
XML is based on nested structure, which means that elements cannot overlap. That is, each element must be contained entirely within another. For example:
<sentence>XML is <emphasis>fun.</emphasis></sentence>
Here, the <emphasis> tag opens and closes inside of the <sentence> tag.
If we were to do this incorrectly, it might look like this:
<sentence>XML is <emphasis>fun.</sentence></emphasis>
Here, the <emphasis> tag starts inside the <sentence> tag, and ends outside it. This is called overlap and it is not allowed in XML.
Elements in XML can have attributes, which in turn have values. Attributes are properties or characteristics of an Element. For example:
<name type="person">Abraham Lincoln</name>
Here, we are using the type attribute with two different values, person and place, to distinguish between two different kinds of names.
To keep these all straight, here is a color coded example:
Elements (tags), attributes, values, content
<sentence type="declarative">This is a sentence.</sentence>
<sentence type="interrogative">Is this a sentence?</sentence>
For XML to be well-formed it must:
XML must also be valid, but validity must be measured against something called a schema (see the next section on validation in oXygen). Because XML itself contains no predetermined set of elements that are possible, a schema will include: