How to Resolve "Extra content at the end of the document" XML Sitemap Error
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
⇨ Click here for the table of contents for Laravel articles
Error Description
The sitemap being created through batch processing
error on line 23 at column 19: Extra content at the end of the document
was displaying this error.
Error Causes
- Missing closing tags
- Improperly formed XML documents
- Extra text in the XML document
The above three reasons could be considered for the error.
In this case, a missing closing tag was the cause
In this case, the error was caused by the XML file missing a closing tag.
In my case,
An error occurred during batch processing, causing it to stop while writing the XML
seems to be the case.
Status of this case (error)
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url></url>
The closing tag for urlset was missing.
Solution for this case (error)
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url></url>
</urlset>
Adding the closing tag resolved the error.
②The XML document is not properly formatted as per XML standards
XML files are often read by programs like crawlers in a format that follows predefined standards.
If the document is not written in the specified format, this error occurs.
Check the document again and ensure that necessary elements and attributes are added correctly.
③Extra text is included in the XML
If there is extra text in the XML, this error message will also be displayed.
Check for any extra text in the XML and if it is outside the XML elements or attributes, it needs to be removed or appropriately enclosed in tags.
Conclusion
That's all for now.
I hope this can be helpful to someone.
For feedback or complaints, please contact via Twitter DM.
Until next time!
Popular Articles
Deploying a PHP 7.4 + Laravel 6 Project to AWS EC2
Implementing Breadcrumbs in Laravel with laravel-breadcrumbs