CodeIgniter PHP 產生 Sitemap

網站建立了Sitemap.xml文件能夠快速地被Google、Bing等收錄且有利於搜尋的檔案。
CodeIgniter產生的方式:
controller

Class Seo extends CI_Controller {

    function sitemap()
    {

        $data = "";//網站的url
        header("Content-Type: text/xml;charset=iso-8859-1");
        $this->load->view("sitemap",$data);
    }
}

views

<?= '<?xml version="1.0" encoding="UTF-8" ?>' ?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc><?= base_url();?></loc> 
        <priority>1.0</priority>
    </url>

    <!-- My code is looking quite different, but the principle is similar -->
    <?php foreach($data as $url) { ?>
    <url>
        <loc><?= base_url().$url ?></loc>
        <priority>0.5</priority>
    </url>
    <?php } ?>

</urlset>

config/routes.php

$route[‘seo/sitemap\.xml’] = “seo/sitemap”;