Faq XML sitemap results not well formatted or shows error, what could be the reason?
XML sitemap results not well formatted or shows error, what could be the reason?

In some cases the standard Joomla XML documents could be broken by 3PD plugins or extensions.

When this occurs the XML sitemap documents will be not well formed and you won't be able to submit and use them.

As a rule of thumb use always raw links as by default instead of the SEF version of the sitemap links, for example:
instead of:

Sitemap links rewriting
The SEF alternate version is used only in particular cases and if the routing is not working fine it could result in HTML code embed in the XML document, especially if sh404sef is installed and not properly configured.

A known issue occurs when Virtuemart is installed and a bugged plugin named 'System - Google Analytics' or 'System - Main Page' are published. These plugins adds extra contents to all Joomla output also to XML documents, that should be kept clean.

Other well known bugged plugins are named:
'System - Google Analytics'
'System - YOOtheme Framework'
'System - True typography'
'System - BT Shortcode'
'System - TM Lazy Load'
'System - JSLazyLoading'
'System - JForms'
'System - Responsive Scroll Triggered Box'
'System - Main Page'
'System - Ba Forms'
'System - Ba Gallery'
'System - AutoAnchor Menu support'
'System - Main Page'
'System - Aikon Super Preloader'
'System - JSJobs Register'
'System - EasyScript'
'System - AutoAnchor Menu support'
'System - vmVendor'
'System - Jubenta cookie solution'
'System - Notification Message Bar'
'System - Add FullAjax'
'System - iWt CookieAlarm'
'System - OpenPotion Head and Body'
'System - BT Product Quick View'
'System - Direct Alias Pro'
'System - Ecwid'
'System - Route66'
'System - AxisMeta Renderer'
'System - Social Meta Tags'
'System - JotMarker'
'System - Phocaopengraph'
'System - ResponsiveEUCookie'
'System - Regular Labs - Email Protector'(fixed in 4.0.7)
'System - Regular Labs - Sourcerer'(fixed in 7.0.1)
'System - Promo Notice Message With Timer'
'System - Iubenda Cookie Solution'
'System - JMS FB Instant Articles K2'
'System - Google Tag Manager'
'System- Admin Branding Reloaded v1.8'
'System - Joomla Web Push Notifications'
'System - Push Notification'
'System - JS Support Ticket icon'
'System - Simple Cookie Consent'
Main Page plugin error
In this case simply unpublish the plugin to solve.
Main Page plugin error
In some other cases incorrect configuration of sh404sef could cause the same issue, follow instructions contained in the pdf document to configure properly your sh404sef component.

Finally the problem could be due to extra white spaces added wrongly to the Joomla! output by some bugged plugin or altered Joomla core files. Check that Joomla is up to date and files are original, notice that if your Joomla! website has been hacked core or plugins files could have been altered.
If all Joomla! files are correct, most probably there is some bugged system plugin adding extra spaces to the Joomla output, in such case unpublish all third party plugins until you find the bad one.

Main Page plugin error