Exemple #1
0
        $dom = new DOMDocument("1.0", "UTF-8");
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        $root = $dom->createElement("urlset");
        $root->setAttribute('xmlns', $this->xmlns);
        $root->setAttribute('xmlns:xsi', $this->xmlns_xsi);
        $root->setAttribute('xsi:schemaLocation', $this->xmlns_schemaLocation);
        $root->setAttribute('xmlns:mobile', $this->xmlns_mobile);
        $i = 0;
        $url = [];
        foreach ($this->scaneados as $link) {
            $url[$i] = $dom->createElement('url');
            $loc = $dom->createElement("loc", $link);
            $url[$i]->appendChild($loc);
            $i++;
        }
        for ($i = 0; $i < count($url); $i++) {
            $root->appendChild($url[$i]);
        }
        $dom->appendChild($root);
        header("Content-Type: text/xml");
        print $dom->saveXML();
    }
}
set_time_limit(0);
$filename = 'sitemap.xml';
$url = 'http://www.dafiti.com.br/';
$ignore = array();
$sitemap = new Sitemap();
$sitemap->set_url($url);
$sitemap->xml();