<?php
header('Content-type: Application/xml; charset="utf8"', true);
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

<?php
$dbhost = "localhost"; //Veritabanın Bulunduğu Host
$dbuser = "root"; //Veritabanı Kullanıcı Adı
$dbpass = "sifre"; //Veritabanı Şifresi
$dbdata = "veritabani"; //Veritabanı Adı

try{
$db = new PDO("mysql:host=".$dbhost."; dbname=".$dbdata."; charset=utf8mb4", "".$dbuser, "".$dbpass);
}
catch(PDOException $mesaj){
echo $mesaj->getmessage();
}

$site = $_SERVER['HTTP_HOST'];
$gun = date("Y-m-d");
$saat = date('H:i:s');
$tarih = $gun . "T" . $saat . "+00:00";
?>
<?php
$icerikler = $db->prepare("select * from icerikler");
$icerikler->execute();
?>
<?php
while ($icerik = $icerikler ->fetch(PDO::FETCH_ASSOC)) {
?>
<url>
<loc>https://domain.com/<?php echo $icerik["sef"]; ?>/</loc>

<lastmod><?php echo $tarih; ?></lastmod>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>
<?php } ?>

</urlset>


Buyrun hocam bunu bu çalışıyor veritabanı ayarlarını ve tablo adlarını kendinize uyarlayabilirsiniz.