Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter output XML in View

I tried to output XML in the view file. The view file is result_view.php and its first line is

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

But I get the error "Content is not allowed in prolog". So how to do this correctly? I use Eclipse + PDT.

like image 837
zihaoyu Avatar asked Dec 13 '22 21:12

zihaoyu


1 Answers

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"?>';?>
like image 90
vaxxis Avatar answered Dec 26 '22 11:12

vaxxis