Help! XML Parsing Error: XML or text declaration not at start of entity

Started by InfoStrides, February 13, 2012, 07:55:52 PM

Previous topic - Next topic

InfoStrides

I am having problem with my sitemap. It returns the follow error.

I search the forums but could not find out the solution. I saw one possible cause of the error... (2 empty lines at the begining of the files which I confirmed in the source files. Please help!

Opera:
XML parsing failed

XML parsing failed: syntax error (Line: 3, Character: 0)

Reparse document as HTML
Error:
XML declaration not at beginning of document
Specification:
http://www.w3.org/TR/REC-xml/
  1:
  2:
  3: <?xml version="1.0" encoding="UTF-8"?>
  4: <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  5: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6: xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9


Firefox:
XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.theinfostrides.com/index.php?action=sitemap;xml
Line Number 3, Column 1:<?xml version="1.0" encoding="UTF-8"?>
^


Chrome:
This page contains the following errors:

error on line 3 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.

mashby

So what happens if you remove the first two empty lines from the source files?
Always be a little kinder than necessary.
- James M. Barrie

InfoStrides

Quote from: mashby on February 13, 2012, 08:04:52 PM
So what happens if you remove the first two empty lines from the source files?

Thanks for prompt response.

Please which particular files are you referring to? Sitemap.template.php, files in the folder "Sitemap-Ext", and Sitemap.php

mashby

My guess is Sitemap.template.php. You had mentioned seeing the possible error.
Always be a little kinder than necessary.
- James M. Barrie

InfoStrides

Quote from: mashby on February 13, 2012, 08:34:48 PM
My guess is Sitemap.template.php. You had mentioned seeing the possible error.

OK. There is not empty space above.

Illori

you would be best to post in the mods support thread so those that use this mod and the author can help you.



MrPhil

If you can post here, you should be able to post in another SMF community board. Is that a restricted board of some sort? Do you get a specific message that you're not permitted to post there?

Look in the .xml file and see if these empty lines are 0 length (just newlines) or if they have some blanks or tabs in them. Then look in the PHP file that produces that file and look for code that would produce those empty lines. Start at the line that outputs <?xml version... and work backwards, looking at each statement that prints to the XML file, until you arrive at the statement that opens the XML file for output. Hopefully by then you'll have found the culprit(s).

Illori


InfoStrides

Quote from: MrPhil on February 21, 2012, 10:35:38 AM
If you can post here, you should be able to post in another SMF community board. Is that a restricted board of some sort? Do you get a specific message that you're not permitted to post there?

Look in the .xml file and see if these empty lines are 0 length (just newlines) or if they have some blanks or tabs in them. Then look in the PHP file that produces that file and look for code that would produce those empty lines. Start at the line that outputs <?xml version... and work backwards, looking at each statement that prints to the XML file, until you arrive at the statement that opens the XML file for output. Hopefully by then you'll have found the culprit(s).

Thank you Phil. I checked but no issue found. One more thing, the issue seems to be global to my forum as the sources of all pages indicate 2 blank lines at the beginning. Don't know what do to!

InfoStrides

Thanks for your guides. I found that a third-party mod (Twitter and Facebook Publisher) is causing the heck on the website. I am looking into it.

If anyone has encounter similar issue with the mod, please post here how you got it resolved.

InfoStrides

If anyone has encounter similar issue with the mod, please post here how you got it resolved.

MrPhil

I am not familiar with this mod. It's not on the SMF site? Can you look at the code it adds, and post any lines that appear to output to a (possibly XML) file? Perhaps there is an output of \n\n somewhere, which is something you would need for CGI output (e.g., Perl code) after the header, but should not go to an XML page. Assuming this mod was tested by the author, it's hard to believe that such an error would get by. Did you modify or adapt it at all? Was this mod ever meant to produce XML output? I'm wondering if it's CGI that was never intended to output XML.

Advertisement: