when I click on the link for the posts http://www.telechargercours.com/post-sitemap.xml I receive an error

XML Parsing Error: not well-formed
Location: http://www.telechargercours.com/post-sitemap.xml
Line Number 14427, Column 34: <image:caption>L'Ordre SELECT Élémentaire</image:caption>

any idea about this error?

Dani AI

Generated

— the parser error in a caption usually means an encoding or escaping problem. was right to look at character encoding, but replacing accented letters with HTML named entities is a fragile fix for an XML sitemap: XML parsers only recognize the five predefined entities by default, so named HTML entities can themselves trigger parse failures. The correct approach is to make the sitemap valid XML by either outputting real Unicode (UTF‑8) or using numeric character references, and by removing any invalid control bytes or byte-order-mark (BOM).

Quick diagnostics (run these against a downloaded copy of the sitemap):

curl -I 'http://your-site/post-sitemap.xml'        # check Content-Type header
curl -s 'http://your-site/post-sitemap.xml' | sed -n '1,6p'  # see XML prolog
file -i post-sitemap.xml                            # detect encoding
xmllint --noout post-sitemap.xml                    # validate XML syntax
iconv -f UTF-8 -t UTF-8 post-sitemap.xml >/dev/null  # fails if invalid UTF-8
hexdump -C post-sitemap.xml | head                  # look for BOM or odd bytes

Fix strategy, in order of preference:

  • Make sure the sitemap output declares and actually uses UTF‑8 (XML prolog and HTTP header must match).
  • Update the sitemap generator plugin and clear any caches so it's not serving stale, mis-encoded output.
  • Edit the offending caption in the Media Library or post metadata so it’s stored as valid UTF‑8.
  • If programmatic sanitization is needed, convert and strip invalid bytes before the sitemap is generated. Example sanitizer to run on captions before they are emitted:
function ensure_utf8_for_xml($text) {
    $enc = mb_detect_encoding($text, ['UTF-8','ISO-8859-1','Windows-1252'], true);
    if ($enc && $enc !== 'UTF-8') $text = mb_convert_encoding($text, 'UTF-8', $enc);
    if (!$enc) $text = mb_convert_encoding($text, 'UTF-8', 'Windows-1252');
    $text = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/u', '', $text); // strip illegal XML controls
    return $text;
}

Notes and cautions: back up the database before changing charsets or running mass edits; test fixes on a staging site; re-validate with xmllint after each change. Replacing characters with HTML named entities is a workaround at best and may break XML parsers — fix the encoding at the source instead.

Recommended Answers

All 2 Replies

I suspect that the character you used for either the É or é is not in the UTF-8 character set.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.