Генератор SiteMap

Здравствуйте.
Хочу сделать автоматическую генерацию карты сайта SiteMap, попадая на которую ПС получает готовый XML код. Пример:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<url>
		<loc>https://site.ru/</loc>
		<lastmod>2022-11-28</lastmod>
		<changefreq>daily</changefreq>
		<priority>0.8</priority>
	</url>
</urlset>

Подскажите, как такое можно сделать?
Спасибо.
В сентябре, 2017 года, я начал писать генератор SiteMap для этого сайта: Тема: Карта сайта (phpFOX: SiteMap).
На данный момент мой генератор выглядит так:
<?php
class phpfox_seo_sitemap
{
	private $map = [
		'blog',
		'forum_thread',
		'photo',
		'poll',
		'video'
	];

	public function __construct()
	{
		foreach ($this->map as $item)
		{
			$rows = phpfox::getLib('database')
				->select('*')
				->from(phpfox::getT($item))
				->execute('getSlaveRows');

			$this->area($item, $rows);
		}
	}

	private function area($item, $rows)
	{
		$path = phpfox::getParam('core.path');
		$url = [];
		foreach ($rows as $row)
		{
			if ($item == 'blog')
			{
				$url['loc'][]        = $path . 'blog/' . $row['blog_id'] . '/';
				$url['lastmod'][]    = !empty($row['time_update']) ? $row['time_update'] : $row['time_stamp'];
				$url['changefreq'][] = 'weekly';
				$url['priority'][]   = '0.5';
			}
			else if ($item == 'forum_thread')
			{
				$url['loc'][]        = $path . 'forum/thread/' . $row['thread_id'] . '/';
				$url['lastmod'][]    = $row['time_update'];
				$url['changefreq'][] = 'daily';
				$url['priority'][]   = '0.5';
			}
			else if ($item == 'photo')
			{
				$url['loc'][]        = $path . 'photo/' . $row['photo_id'] . '/';
				$url['lastmod'][]    = $row['time_stamp'];
				$url['changefreq'][] = 'yearly';
				$url['priority'][]   = '0.5';
			}
			else if ($item == 'poll')
			{
				$url['loc'][]        = $path . 'poll/' . $row['poll_id'] . '/';
				$url['lastmod'][]    = $row['time_stamp'];
				$url['changefreq'][] = 'yearly';
				$url['priority'][]   = '0.5';
			}
			else if ($item == 'video')
			{
				$url['loc'][]        = $path . 'video/' . $row['video_id'] . '/';
				$url['lastmod'][]    = $row['time_stamp'];
				$url['changefreq'][] = 'yearly';
				$url['priority'][]   = '0.5';
			}
		}

		$file = phpfox::getParam('core.dir_sitemap') . $item . '.xml';
		$this->creation($url, $file);
	}

	private function creation($url, $file)
	{
		$count = count($url['loc']);

		$xml  = '<?xml version="1.0" encoding="UTF-8"?>'                       . "\r\n";
		$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";
		for ($i = 0; $i < $count; $i++)
		{
			$xml .= "\t"   . '<url>'                                                               . "\r\n";
			$xml .= "\t\t" . '<loc>'        . $url['loc'][$i]                    . '</loc>'        . "\r\n";
			$xml .= "\t\t" . '<lastmod>'    . date('Y-m-d', $url['lastmod'][$i]) . '</lastmod>'    . "\r\n";
			$xml .= "\t\t" . '<changefreq>' . $url['changefreq'][$i]             . '</changefreq>' . "\r\n";
			$xml .= "\t\t" . '<priority>'   . $url['priority'][$i]               . '</priority>'   . "\r\n";
			$xml .= "\t"   . '</url>'                                                              . "\r\n";
		}
		$xml .= '</urlset>';

		$fopen = fopen($file, 'w');
		$write = fwrite($fopen, $xml);
		fclose($fopen);
	}
}

Возможно, Вам поможет мой класс, как пример создания генератора карты.