Faq Why XML sitemap has error 'Call to undefined method Joomla\CMS\Document\RawDocument::addCustomTag()'
Why XML sitemap has error 'Call to undefined method Joomla\CMS\Document\RawDocument::addCustomTag()'

This is not a problem of the JSitemap component, this means that you have installed a bugged plugin.

This error means that the standard Joomla XML documents has been broken by 3PD plugins or extensions not dealing correctly with various Joomla! formats other than plain HTML.
As a result you experience an error such as:
'Call to undefined method Joomla\CMS\Document\RawDocument::addCustomTag()' or 'Call to undefined method Joomla\CMS\Document\XmlDocument::addCustomTag()'.

A blacklist of well known bugged plugins are:
'System - Google Analytics'
'System - 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 - Simple Cookie Consent'

In this case simply unpublish the plugin to solve. If this list does not contain a plugin installed on your website you have to unpublish each plugin one by one until you find the one having the bug and the problem fixes.
Main Page plugin error

If you can't unpublish a bugged plugin because it's mandatory for the website, you can report the problem to the plugin developer so that they will be able to fix it.