tags:

views:

22

answers:

1

Hello all,

I am trying to fix an error for a friend in his site that someone else has written and I am having a real hard time with one of these errors. There is functionality to check wether a user can use a username via AJAX, the response is XML. However, the XML returned has an error in it.

XML Parsing Error: XML or text declaration not at start of entity Location: moz-nullprincipal:{17ec3adb-5ee9-437a-b047-8910f6faa55c} Line Number 2, Column 1:

<?xml version="1.0" encoding="UTF-8"?><ajaxResponse><cunamemsg>1</cunamemsg></aj...
^

When I look at the actual response, it looks like this:

<?xml version="1.0" encoding="UTF-8"?><ajaxResponse><cunamemsg>1</cunamemsg></ajaxResponse>

It has a white line at the top, which I am guessing is causing the JS error in conjunction:

cunameresult.getElementsByTagName(

if(cunameresult.getElementsByTagName('cunamemsg').item(0).firstChild.data==0) 

To be honest, I have no idea what else to check. I've checked each PHP script referenced for any white space.

Is it possible that PHP notices can cause the XML returned to have an extra line? There are quite a few PHP notices and warnings being logged that are within the same script but they refer to variables being un-initialised.

Thanks all for any help on this and what direction to take to find a solution.

+2  A: 

Make sure you have no white space before the opening <?php or anywhere in the included PHP scripts - it would be visible in the XML result as well.

Pekka
Thanks, this will save someone some time, I'm sure!
Abs