XML CodeIgniter output in view

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

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

But I get the error "Content is not allowed in the prolog." So how to do it right? I am using Eclipse + PDT.

+4
source share
5 answers

I don't know if this caused any problems, but I disabled the short open PHP tag in the .htaccess file and <?xml worked. PHP no longer tried to parse <? like a php script.

+1
source

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

Put this at the top of your view file:

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

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

Try opening the file in an editor that allows you to delete any specification (for example, Notepad ++) or an editor with the ability to view files in hexadecimal format. There are also several tools that you can use to remove specifications. Google for more information, as the tool you use will depend on your situation and environment.

+2
source
 <&#063;xml version="1.0" encoding="utf-8" standalone="yes"&#063;> 

It looks good in html, BUT then the receiver (application) should replace and#063; on ? .

+1
source

Why are you using php tags to output a simple string?

How to simply put this at the top of your view:

 <?xml version="1.0" encoding="UTF-8"?> 
-1
source

Source: https://habr.com/ru/post/1310517/


All Articles