An XML Document

An XML document has the following general structure but some parts are optional:

  • A prolog, which may optionally be empty

  • At least one element, the document element, although a typical XML document has a nested structure of elements

  • Optional content following the end tag of the document element

Each of these permitted parts of an XML document is described in the remaining sections of this chapter.

A minimal XML document can consist of a single document element, such as this:

<someElementTypeName>The content</someElementTypeName> 

Typically, XML documents are much more complex and have a nested structure of elements. An XML document that uses more of the allowed structures might look like this:

 <?xml version="1.0" ?> <!-- This ...

Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.