Structure of an XML document

An XML document is always made up of two character types: the actual data and the so-called tags or markups. Tags are XML instructions, which describe the division of the document into storage units and its logical structure. The structure itself is saved in a document type definition (DTD).

Tags are always written in pairs in angle brackets. Every start tag always has a corresponding end tag.

XML attributes are used within the tags. An attribute may only occur once within a tag.

XML documents consist of elements. An element is made up of two XML tags and the enclosed text. Blank elements consist of only one tag and always end with a slash (/) before the final bracket.

You can create simple XML documents with a text editor. In the following example, the DTD is specified in square brackets in the XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE memberlist

[

<!ELEMENT memberlist (no, name, age)>

<!ELEMENT no (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT age (#PCDATA)>

]>

<memberlist>

<no>001</no>

<name>Doe, John</name>

<age>27</age>

</memberlist>

If you save this document under the name of your choice with the extension .xml, Internet Explorer can display the document in a structured form.