XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 10th, 2004, 04:16 AM
indivision's Avatar
indivision indivision is offline
Flash Master / PHP Jester
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Redondo Beach, CA
Posts: 132 indivision User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 2 m 16 sec
Reputation Power: 8
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?
__________________



-Joe

Reply With Quote
  #2  
Old February 10th, 2004, 01:15 PM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
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.

Reply With Quote
  #3  
Old February 10th, 2004, 03:27 PM
indivision's Avatar
indivision indivision is offline
Flash Master / PHP Jester
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Redondo Beach, CA
Posts: 132 indivision User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 2 m 16 sec
Reputation Power: 8
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Are XML headers necessary?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT