$locations * @return Generator */ public function chunks(iterable $locations, bool $index = false): Generator { $root = $index ? 'sitemapindex' : 'urlset'; $item = $index ? 'sitemap' : 'url'; yield ''."\n"; yield '<'.$root.' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"; foreach ($locations as $location) { yield '<'.$item.'>'.htmlspecialchars($location, ENT_XML1 | ENT_QUOTES, 'UTF-8').''."\n"; } yield ''; } }