An XML document contains text, never binary data. It can be opened with any program that knows how to read a text file. Example 2-1 is close to the simplest XML document imaginable. Nonetheless, it is a well- formed XML document. XML parsers can read it and understand it (at least as far as a computer program can be said to understand anything).
Example 2-1. A very simple yet complete XML document
<person> Alan Turing </person>
In the most common scenario, this document would be the entire contents of a file named person.xml , or perhaps 2-1.xml . However, XML is not picky about the filename. As far as the parser is concerned , this file could be called person.txt , person , or Hey you, there's some XML in this here file! Your operating system may or may not like these names , but an XML parser won't care. The document might not even be in a file at all. It could be a record or a field in a database. It could be generated on the fly by a CGI program in response to a browser query. It could even be stored in more than one file, although that's unlikely for such a simple document. If it is served by a web server, it will probably be assigned the MIME media type application/xml or text/xml . However, specific XML applications may use more specific MIME media types, such as application/mathml+xml , application/xslt+xml , image/svg+xml , text/vnd.wap.wml , or even text/html (in very special cases).
| || |
For generic XML documents, application/xml should be preferred to text/xml , although many web servers come configured out of the box to use text/xml . text/xml uses the ASCII character set as a default, which is incorrect for most XML documents.