To make your sitemaps human-readable in web browsers, you can add an XSL stylesheet processing instruction. Use the setStylesheet() method on either a Sitemap or SitemapIndex instance. Pass the path to your XSL file as a string (e.g., '/sitemap.xsl').
If you use maxTagsPerSitemap on a Sitemap that has a stylesheet set, the stylesheet will automatically be propagated to both the generated sitemap index and all resulting chunk sitemaps.
use Spatie\
Sitemap\Sitemap;
use Spatie\Sitemap\SitemapIndex;
// For a single sitemap
Sitemap::create()
->setStylesheet('/sitemap.xsl')
->add('/page1')
->writeToFile($sitemapPath);
// For a sitemap index
SitemapIndex::create()
->setStylesheet('/sitemap-index.xsl')
->add('/pages_sitemap.xml')
->writeToFile($sitemapIndexPath);