The XML Declaration

An XML document can (and should, according to the W3C) start with an XML declaration, which can indicate that the document is written in XML. If you use an XML declaration, it should be the first line in the document. Nothing should come before the XML declaration. Here's an example:

 <?xml version = "1.0" standalone="yes" encoding="UTF-8"?> 

The XML declaration uses the <?xml?> element; in earlier drafts of XML, that was <?XML?> , but it was made lowercase in the final recommendation, and it's an error to use upper case. (You'll still find applications out there that insist on the original uppercase version; browsers such as Internet Explorer accept either version.)

There are three possible attributes you can use in the XML declaration:

  • version The XML version. Currently, only 1.0 is possible here. This attribute is required if you use an XML declaration.

  • encoding The language encoding for the document. As discussed in the previous chapter, the default here is UTF-8. You can also use Unicode, UCS-2 or UCS-4, and many other character sets, such as ISO character sets. This attribute is optional.

  • standalone Set to yes if the document does not refer to any external entities; set to no otherwise . This attribute is optional; the default value is yes .



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net