user838037
user838037

Reputation: 343

XML Parsing Error: not well-formed

I am creating a sitemap XML from my database it's about videos sitemap. In XML, I am fetching the video title as title and description as description, but there are some titles and descriptions written in Thai, Portuguese, German, and other languages. While generating the XML through PHP I am facing a problem that says:

"XML Parsing Error: not well-formed".

Generation of the XML stops after encountering this error.

XML Parsing Error: not well-formed
Location: http://localhost/mydesk/sitemap.php
Line Number 24489, Column 69:

I observed it contained invalid characters like listed below, and I have replaced all types of these characters, but I realized there are other characters being used in other languages.

Ð ž ´ Ø ¸ à ½ Ð ‰ ˆ Ù ° § ¼ ¡ ‹ ± …  ³ è ¾ Ñ € ¦ ƒ Ñ ‡ ª Ñ Ï ¿ ¬ µ š † Ð ½ ¹ Œ ² Ð ¼ Î ¶ € Ð µ ] : å < * © > % â © # " ' ä æ ï ã Š ç › Š º Ž ¥ œ • ¤ ç ã ® ˜ ¢ ¨ ¯ £

Is there any way to handle this issue that supports all languages?

Upvotes: 18

Views: 106724

Answers (4)

FDisk
FDisk

Reputation: 9416

If you get this error message try to view the page source by pressing Ctrl+U Usually, there is a " symbol in the wrong place. Double-check your XML syntax.

Upvotes: 11

Gabriel Arghire
Gabriel Arghire

Reputation: 2360

Use an XML Validator tool. You can find one online here

In my case, it showed me the exact line and column of the error.

Upvotes: 1

ekkev
ekkev

Reputation: 56

I had the same error in Firefox, parsing an SVG string, and it only disappeared with "text/html" as mimeType. I had tried 'image/svg+xml' and 'application/xml' before and found in the https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString manual they are functionally equivalent anyway, so I tried..

Upvotes: 1

mister270
mister270

Reputation: 366

Can you open your xml document in a hex editor? If so see if it takes 1 byte per character or 2. If it takes 2 bytes per character you should try UTF-16 for encoding instead. If you do keep in mind that the only encoding you can guarantee a parser will support is UTF-8. Should support UTF-16 too but not all do.

Upvotes: 1

Related Questions