29837 01 pp001-288 r9ah.ps 8/18/03 4:40 PM Page 1
Include an XML Declaration
Although XML declarations are optional, every XML document should
have one. An XML declaration helps both human users and automated
software identify the document as XML. It identiﬁes the version of XML
in use, speciﬁes the character encoding, and can even help optimize the
parsing. Most importantly, it’s a crucial clue that what you’re reading is in
fact an XML document in environments where ﬁle type information is
unavailable or unreliable.
The following are all legal XML declarations.
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<?xml version="1.0" standalone="yes"?>
In general the XML declaration must be the ﬁrst thing in the XML docu-
ment. It cannot be preceded by any comments, processing instruction, or