XML technologies / XML / XML in a Nutshell / XML basics / XML documents and XML files
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
An XML document contains text, never binary data. Any program capable of reading a text file can open it. The following code example shows almost the simplest possible XML document, which is nevertheless well-formed. XML parser can read and understand it, insofar as a computer program can be said to understand anything.
<person>
Alan Turing
</person>Code example: a very simple but complete XML document
Most commonly, this document would be the entire contents of a file named person.xml or perhaps 2-1.xml. XML is not particular about filenames, however. As far as the parser is concerned, the file could also be called person.txt, person or Hallo, hier ist ein bisschen XML in dieser Datei!. Your operating system might object to these names, but an XML parser does not care. The document need not even be in a file: it could be a database record or field, or be generated by a CGI program in response to a browser request. It could even span several files, although that is unlikely for such a simple document. When served by a web server, it will probably be associated with the MIME type application/xml or text/xml. Specific XML applications may use more specialized MIME types, such as application/mathml+xml, application/xslt+xml, image/svg+xml, text/vnd.wap.wml or text/html (in special cases).
Warning: For ordinary XML documents, use application/xml, not text/xml, although most web servers are configured by default to use text/xml. text/xml defaults to ASCII, which is incorrect for most XML documents.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top