|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Are XML headers necessary?
I see in many XML files this line at the beginning:
<?xml version="1.0"?> If I take it out, the XML continues to load into flash the same way it did before (on IE). Do I need to include this header when generating xml? What is the purpose of this line? |
|
#2
|
||||
|
||||
|
It is referred to as the XML declaration. IE will handle the content of a file without the declaration if the file extension is .XML, otherwise it will treat it as a text file.
It is a good practice to include this at the top of all your XML documents for 3 reasons (that I can think of): 1. It defines the version, character encoding, and other information. Right now there is version 1, but in the future if there is a version 2 whatever is handling your document may assume that it was written in version 2 without the declaration. 2. While we are on the subject of programs that handle XML documents, most applications that use XML documents as input may error out without the declaration. Without it, the document is considered well-formed, but not valid. The spec for XML is here, http://www.w3.org/TR/2004/REC-xml-20040204/#NT-SDDecl, but may be difficult for some to follow. 3. Sometimes you are streaming XML instead of reading it directly from a file. In this case, without the XML declaration, whatever is using the stream may not accept it as XML because it can't not determine if the data in the stream is valid XML. Hope this helps. Post more questions if you would like. |
|
#3
|
||||
|
||||
|
That helps a lot. Thank you.
I will include it then. That XML manual should answer my other questions. I didn't know that existed! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Are XML headers necessary? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|