XML technologies / XML / Perl & XML / Introduction to XML / The XML declaration

(Excerpt from "Perl & XML" by Erik T. Ray & Jason McIntosh)

After reading about character sets and their encoding, an attentive reader may wonder how to tell the XML processor which character set and encoding are intended. The answer is that the encoding and character set are specified in the XML declaration. The XML declaration is the first line of a document. It describes the markup it contains, including the XML version, character set and possible use of an external subset of the DTD. The declaration looks like this:

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

The declaration is optional. With the exception of version, so are its attributes. The encoding parameter matters only when using a character set other than UTF-8 (the default character set) (Note: in Germany, this will almost always be ISO 8859-1, the official name of ISO Latin-1). If the declaration of version to "yes", a validating parser will report an error if the document uses external Entities.

  

  

 

 

 

back to top