CodeIgniter output XML in View CodeIgniter output XML in View codeigniter codeigniter

CodeIgniter output XML in View


One easy solution is to set php header in the view file and then echo the xml header.

Put this in the top of your view file:

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


This error seems to indicate that you have data before your <?xml ?> declaration. You might have a Byte Order Mark at the beginning of your file.

Try opening your file in an editor that will allow you to remove any BOM (such as Notepad++), or an editor with the capability to view files in hexadecimal format. There are also several tools you can use for removing BOMs. Google for more info, as the tool you use will vary depending on your situation and environment.


I don't know if this causes any problem, but I disabled PHP short open tag in .htaccess file, and <?xml worked. PHP no longer attempted to parse <? as php script.