Which setup are you using, i.e. which webserver, browser...?
In case you're using Firefox, there's a nifty little extension
LiveHTTPHeaders that allows you
to watch which HTTP headers are being exchanged between browser and
If that doesn't help you to debug the "bad header" issue yourself,
just post the respective headers that LiveHTTPHeaders (or some similar
tool for your browser) is reporting.
The print header('text/xml'); suggested by virtualsue
works fine for me (using Apache / Firefox), so I suppose your problem
is no longer related to the script code itself...