XML parsing error: malformed

I am creating a sitemap XML file from my video sitemap database. In XML, I select the title of the video as title and the description as description , but there are some names and descriptions written in Thai, Portuguese, German and other languages. While generating XML through PHP, I ran into a problem that reads:

"XML parsing error: malformed."

XML generation stops after this error occurs.

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

I noticed that it contains invalid characters, as indicated below, and I replaced all types of these characters, but I realized that other languages ​​use different characters.

ž ž ¸ ¸ à ½ ‰ Ù ° ¼ ≤ ± ± ± ±  ¾ ¾]]]]]] μ]: & thetas; * ©>% â © # "'ä æ ï ã Š ç>> Š º Ž ¥ œ ¤ ç ã ® ~ ¢ ¨ ¯ £

Is there a way to deal with this problem that supports all languages?

+6
source share
2 answers

If you get this error message, try looking at the page source by pressing Ctrl + U. Usually there is a symbol in the wrong place. And check your html syntax.

+2
source

Can you open your XML document in a hex editor? If so, see if 1 byte per character is required or 2. If it takes 2 bytes per character, you should try instead of UTF-16 for encoding. If you remember that the only encoding you can guarantee to the parser will support UTF-8. UTF-16 should also be supported, but not all.

0
source

Source: https://habr.com/ru/post/912642/


All Articles