Example 2-8. An XML document encoded in Latin-1
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<person>
Erwin Schrödinger
</person>
The encoding attribute is optional in an XML
declaration. If it is omitted and no metadata is available, then the
Unicode character set is assumed. The parser may use the first
several bytes of the file to try to guess which encoding of Unicode
is in use. If metadata is available and it conflicts with the
encoding declaration, then the encoding specified by the metadata
wins. For example, if an HTTP header says a document is encoded in
ASCII but the encoding declaration says it's encoded
in UTF-8, then the parser will pick ASCII.