views:

24

answers:

1

I have this PHP file:

<?php
header('Content-type: text/xml; charset=UTF-8');
?><?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="hello world example" /> 
  <Content type="html">
     <![CDATA[ 
       Hello, world!
     ]]>
  </Content> 
</Module>

I would expect it to return a Content-type:text/xml header.

What it does however is to return Content-Type:text/html

You can have a look at the result over here: http://knox.orgapage.de/hello.php

If I change the file extention to .xml (without the PHP tags of course), everything works fine. I however want to generate the content dynamicaly with PHP.

Any suggestions how to solve this? How can I let the browser know, that it should interpret the content as XML?

+3  A: 

it does not output any text as well.
I assume it is because of some error on the PHP side
You have to refer to error log and repair that error.

yeah that's it

<?php
header('Content-type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>

<Module>
  <ModulePrefs title="hello world example" /> 
  <Content type="html">
     <![CDATA[ 
       Hello, world!
     ]]>
  </Content> 
</Module>

will solve your problem

Col. Shrapnel
Nice! Thanks. That works.
JochenJung