Introduction XML CODE




The XML declaration is followed by the document’s root element, which is usually referred to as the
document element. In the following example, the document element is named books:

<?xml version=”1.0”?>
<books>

...

</books>

The document element is not optional; every document must have one. The following XML is legal
because book elements are nested within the document element books:

<?xml version=”1.0”?>
<books>

<book>

...

</book>
<book>

...

</book>

</books>

The document in the next example, however, is not legal because it lacks a document element:

<?xml version=”1.0”?>
<book>

...

</book>
<book>

...

</book>

If you run the previous XML through a parser, the XML will not load properly, complaining about the
non-existence of the root element.