![]()
Annotations of content with meta-level information are called markup. Markup is achieved by the use of tags
They are quite simply represented by: A “Lesser Than” symbol < followed by the “Tag ID” followed by a “Greater Than” symbol >
If that sounded complex, let us look at a few examples of tags, which will clarify the issue: <title> is an example of a tag for the “title” of an article <abstract> is an example of a tag for the “abstract” of an article < author> is an example of a tag for the “author” of an article <b> is an example of a tag for “boldface” in an article

In the figure on the left is the document without markup. The text in red is supposed to be the title that in green is the author’s name while blue represents the abstract which should be italicized and finally orange represents the body text some of which marked in pink must be bold face. ;
The XML version of this document is shown on the right. Notice the tags (shown in bold) for the title, author, abstract, italics, body and boldface.
If you note carefully, there are two types of tags. One type is those that only have the tag name within the signs < and >. For example the tag
The former is the called the start tag while the latter is called the end tag or close tag. And the content is placed between the start and the end tags.
The start tag and the end tag are said to markup the content within
For instance, in the line
There are two key points to bear in mind when creating XML documents. They must be:
Valid implies that an XML document is compliant with the Document Type Definition (DTD) or Schema that it is supposed to instantiate. We will study validity in a later chapter of this tutorial.
Well formed refers to the document being compliant with general XML rules. Since we just discussed tags and markup, let us consider the main rules for well formed ness related to these (tags and markup). As we progress through this tutorial, we will encounter many more rules for well formedness.
Finally, for a thorough discussion of all the constraints for well formedness and validity, you are advised to refer to http://www.w3.org/TR/1998/REC-xml-19980210#sec-well-formed
A start tag must be balanced with an end tag
Correct: <title>XML Demystified </title>
Incorrect: <title>XML Demystified
Incorrect
Correct: <br/>
The first row is correct, since the tags <title> and </title> are balanced. The second row is incorrect for the very opposite reason. The third row is a special case of a balanced pair of tags <br> </br> with no content within. In this case the element can be represented as <br/>. Note that the forward slash is at the end of the tag name for empty elements. Those familiar with XHTML will recognize this as the line break element.
Tags must be placed in a strictly nested order
<abstract><i> The abstract </i>/abstract> Correct abstract
<abstract><i>The abstract</abstract></i> Incorrect
In both rows above the star and end tags are balanced. However, in the top row the tags are nested properly i.e. the <i> and </i> are completely nested within the <abstract> and </abstract> tags. This is correct. In the lower row, the inner <i> tag is not ended when the /abstract> end tag is encountered. This implies that the tags are not nested correctly. Testing for Well Formed ness / Validity All XML parsers (programs which can read an XML file and construct a programmatic stricture out of it) will perform a well formed ness check on XML documents. Some parsers called validating parsers will also perform a validity check on the document by comparing the document against the DTD or schema. An excellent online tool for checking well formed ness can be found at RUWF: http://www.xml.com/pub/a/tools/ruwf/check.html I would suggest you key in the above correct and incorrect markup and test it against this checker as an exercise. You can also check validity of documents at the following site (though you might want to wait till a later chapter to really understand DTD and Schemas, before you try this out): http://www.stg.brown.edu/service/xmlvalid/
Now let’s move on to the very “legally mine or yours?” part of XML – the concept of namespaces. Namespaces, as we will see are ways of clearly defining without ambiguity the origin of any markup. Onward bound!