![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Learn XML programming in this free XML training course How is the XML declaration used?Ok, I’m going to let you in on a secret. The XML declaration, just like the HTML declaration in HTML documents, is actually optional. It doesn’t have to be there… many programs can still handle XML data fine even if it’s not. So why should you even include it? The answer is simple, really… the declaration makes sure that whatever encounters the file knows that it’s XML. If it’s a human user looking at the file, then they know what they’re seeing and which version of it they’re going to be dealing with. If it’s a program, it lets it know which language it needs to process in just in case the program didn’t automatically use XML. Besides, it’s just one line… that’s not a lot of input for a guaranteed declaration that you’re using XML. Of course, there are different ways to use your XML declaration… the one that’s been referenced here is just the most basic. In all, there are 4 different options depending upon the information that you want to pass on: <?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <?xml version="1.0" standalone="yes"?> Notice that all four options tell the number of the version of XML that’s being used. The second option introduces encoding, which tells the character set that the document is written in. The third lists the encoding (notice that there is more than one option), as well as introducing the standalone option… a way to let the reader or program know whether or not the XML document needs an external DTD for processing. And of course, the fourth version omits the encoding but keeps the standalone information. So what does all of this mean in regards to creating XML? Not a lot, really. The basic declaration is all that you’ll need for most of your XML projects… while you can put in additional information if you wish, most programs and users would be able to tell rather quickly whether or not you were using a different character set or if there was an external DTD needed. If you really want to be thorough, though, feel free to use one of the more elaborate declarations… after all, if you’ve got the information in the declaration then you know that you’ve covered all of your bases.
by John Casteele Find more free Internet tutorials from Learnthat.com. More Information:
Help us by rating this tutorial: [---] [--] [+] [++] [+++] [---] lowest; [+++] highest
|
|
||||||
![]() |
Learn: Free
Tutorials - Links
to Free Tutorials
Understand: Free Technical Definitions
- ExplainThat Whitepapers
Use: Certification Section -
Discussion Forum
Visit Our Network Sites:
About Us : Contact Us : Advertise : Privacy Information