Topics

Next topics

Step One: Make an XML Declaration

The goal of this step is to create an XML declaration, which declares the nature of XML documents to document readers. Without this declaration, a document reader might mis-identify an XML document as SGML, HTML or RTF, causing interpretation problems.

Every XML document should use an XML declaration, to state its nature to XML document readers. Editors, browsers and document processors use the declaration to determine how a document should be processed. The declaration becomes increasingly important with large and complex documents but should also be used in smaller and experimental documents. The XML declaration includes information on markup language, markup language version, presence of external markup declarations and character encoding.

Your Well-Formed XML Instance

You should build your own XML document, as you go through the tutorial. Look to Your Well-Formed XML Instance as you read through the tutorial, for guidance and as an example. Your document may be quite different than this example but should be built in a similar way. Your document should begin with an XML declaration and should be identical to this document at this early stage of document development.

<?xml version="1.0" standalone="yes"?>

XML Declaration

These XML declarations are commonly used for various types of XML authoring. The first two declarations can be used to describe well-formed and valid XML documents, respectively. The third declaration can be considered the default XML declaration, stating that it is an XML version 1.0 document, that it cannot standalone from external markup declarations and that it is encoded in UTF-8, an 8 bit Unicode character encoding. Use the first XML declaration when creating your own well-formed XML documents.

<?xml version="1.0" standalone="yes"?>
<?xml version="1.0" standalone="no"?>
<?xml version="1.0" standalone="no" encoding="UTF-8"?>

XML Declaration Components

Term
Meaning
<?xml
Starts the XML declaration, a type of processing instruction.
version
The version declaration describes the version of XML being used, which must be made equal to "1.0", as XML 1.0 is the current and only version of XML.
standalone
The Standalone Document Declaration allows the document author to specify whether external markup declarations may exist. This attribute can be equal to yes or no and is always the former in well-formed documents.
encoding
The encoding declaration allows authors to specify the character encoding that they are using. This declaration only needs to be used by authors that are using a character encoding other than US-ASCII, the most common, or UTF-8.
?>
Closes the XML declaration.