ホーム > Other > How to Resolve Error Expecting in XML File
Other

How to Resolve Error Expecting in XML File

Thank you for your continued support.
This article contains advertisements that help fund our operations.

⇨ Check out the table of contents for Laravel articles here

Error Description

When checking the image sitemap (XML), an error was encountered with the following message.

error on line 100 at column 39: EntityRef:

Error Cause

XML files cannot use symbols like "&".

Therefore, it seems necessary to use the escape character

&

Resolving the Error

It is recommended to convert the "&" part in the string to escape characters.

Therefore,

PHP

$str = htmlspecialchars($str, ENT_NOQUOTES);

JavaScript

var result = encodeURIComponent(str)

By using the string converted to escape characters to generate the sitemap, the error should be resolved.

Summary

That's all.

I hope this can be helpful to someone.

For feedback or complaints, please contact via Twitter DM.

Thank you!

Popular Articles

Deploying PHP7.4 + Laravel6 Project to AWS EC2

Implementing Breadcrumbs in Laravel with laravel-breadcrumbs

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!