Technically, an XML document is any sequence of Unicode characters that is well formed according to the rules laid out in the XML 1.0 specification. Such a document may or may not be stored in a fileit can be stored in a database record, created in memory by a program, read from a network stream, printed in a book, painted on a billboard, or scratched into a subway car window. There is not necessarily a file anywhere in the picture. If the XML document is stored in a file, it may be in a single file or split across multiple files using external entity references. It's even possible for multiple XML documents to be stored in a single file, although this is unusual in practice.
When discussing XML documents it is sometimes useful to distinguish the documents themselves from the DTDs or other forms of schemas. In these cases, the actual document that adheres to the schema is called an instance document . Here the document is an instance of a particular schema.