The XML Declaration Must Come First

As the text makes clear, the XML declaration or the text declaration (if you have one) has to be the first thing in the entity (if you're not up on entities yet, assume for the moment that an entity is a file). This does not mean the first non-blank thing in the entity, it means right at the front of the entity; the first bytes a program gets when it opens the file and starts reading.

Back-link to spec

Copyright © 1998, Tim Bray. All rights reserved.