views:

195

answers:

3

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.

A: 

Why are you using php tags to echo out a simple string?

How about just putting this at the top of your view:

<?xml version="1.0" encoding="UTF-8"?>
bschaeffer
Short tags... (15 chars)
Daniel
@Daniel Yes short tags seem to be the problem
zihaoyu
+2  A: 

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.

John Factorial
+1  A: 

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.

zihaoyu
That was going to be my next move.. but there should be a better work around besides that.
bschaeffer