Jump to content

Error loading sitemap-xml.php


Recommended Posts

Hi everyone,

I’m running into a persistent issue when trying to serve a sitemap in ProcessWire via a custom sitemap-xml.php template. When I visit the page at /sitemap.xml, the browser shows this error:

error on line 1 at column 50: Space required after the Public Identifier

I’ve double-checked that the output starts with the proper XML declaration:

header("Content-Type: application/xml; charset=UTF-8");
echo '<?xml version="1.0" encoding="UTF-8"?>';

Despite that, the error still shows up. The page is returning XML generated dynamically using httpUrl, and there might be other elements or layout markup leaking into the response.

I suspect it could be related to BOM characters, extra whitespace before the <?php tag, or ProcessWire wrapping the output with a layout file like _main.php.

I’ve tried setting return renderSitemapXML(); instead of echoing it, and ensured htmlspecialchars(..., ENT_QUOTES | ENT_XML1, 'UTF-8') is used in <loc> elements. Still no luck.

 

Any advice on how to completely prevent PW from rendering the full HTML layout and just serve a clean XML output?

 

Thanks in advance!

Link to comment
Share on other sites

While I've never encountered that particular error, I have solved other ones by removing empty lines from beneath the closing php tag in my ready.php file.

Link to comment
Share on other sites

19 hours ago, nexuspolaris said:

Any advice on how to completely prevent PW from rendering the full HTML layout and just serve a clean XML output?

Hi,

if you're using markup region and thus append the _main.php file to tour template, just go to your sitemap model config  and check this checkbox (files tab) to prevent appending the full html thing around your xml 🙂

have a nice day

image.png

  • Like 1
Link to comment
Share on other sites

On 5/10/2025 at 1:03 PM, virtualgadjo said:

Hi,

if you're using markup region and thus append the _main.php file to tour template, just go to your sitemap model config  and check this checkbox (files tab) to prevent appending the full html thing around your xml 🙂

have a nice day

image.png

Thank you so much, you saved my day.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...