views:

278

answers:

2

My backend program generates some XML data and sends them to the client. The backend response is like this:

print $cgi->header("Content-type: text/xml;charset=utf-8");
print "<?xml version='1.0' encoding = 'utf-8'?>";

< correct XML data goes here >

When I try to visualize the sent XML in Firefox, It gets the whole thing and everything is fine. But under Chrome and IE the XML header isn't received and XML data isn't displayed as it should (only like a plain text)!

What's wrong with this?

+5  A: 

Try refactoring your code

print header(-type=>'text/xml' , -charset=>'UTF-8');

See the CGI.pm docs on CREATING A STANDARD HTTP HEADER

Anand
Thank you so much, now everything is working just fine! thanks again
Yngwie
Even this works fine: header("text/xml;charset=utf-8");
Yngwie
Glad I could help :-)
Anand
A: 

It might not like the spaces between encoding = 'utf-8' try encoding='utf-8' I can't answer how chrome and IE parses xml but it could be as simple as that.

Jonas B