XML Parsing Error: XML or text declaration not at start of entity
I encountered this error when tried to generate xml file from PHP:
XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.ilmuit.com/feed.php?tutorial
Line Number 2, Column 1:
<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>
^

When I view the page source, I notice there is a space before the xml header (see below). An extra white line just before the <?xml tag. That was the cause of the error message.

Most likely reason for this error is some white space before XML content. Probably there is a line break before the XML declaration at the top of the file. I checked all the PHP source code manually for unseen characters before the first <?php tag in every files including my config.php, mysql_connect.php, header.php and any other files that required to render the XML page.
Finally I fixed this by open the source file, and hit the backspace key to remove any whitespace, before <?php and after ?> php close tag.
Removing all the blank lines fixed the error and my feed started working fine. Hope this guide can help someone out.



FACEBOOK
GOOGLE+
TWITTER
RSS



