Name

XML Declaration

Synopsis

                        <?xml version="
                        version_number
                        " [encoding="
                        encoding-name
                        "][standalone="
                        yes|no
                        "]?>

The XML declaration serves several purposes. It tells the parser what version of the specification was used, how the document is encoded, and whether the document is completely self-contained or not.

Tip

If you need to create an XML document that takes advantage of XML 1.1 features, you need to set the version pseudo-attribute to 1.1:

<?xml version="1.1"?>

The XML declaration, if included, must be the first thing that appears in an XML document. Nothing, except possibly a Unicode byte-order mark, may appear before this structure’s initial < character. If no XML declaration is present, the document is assumed to conform to the XML 1.0 Recommendation.

Get XML in a Nutshell, 3rd Edition 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.