XML Tutorial/Introduction/XML Declarations

Материал из Web эксперт
Перейти к: навигация, поиск

XML provides the XML declaration to label documents as XML.

A declaration must include the version, but the encoding and standalone attributes are optional.
The version, encoding, and standaloneattributes must be in that order.
The XML declaration must be right at the beginning of the file. 
A typical XML declaration looks like this: 
<?xml version="1.0" encoding="UTF-16" standalone="yes"?> 
<name first="Bond" 
      middle="James" 
      last="Last"/> 
An XML declaration can be as full as the previous one or as simple as: 
<?xml version="1.0"?> 
Because the XML declaration is a processing instruction and not an element, there is no closing tag.