Location: PHPKode > scripts > Google SiteMap generator > google-sitemap-generator/sitemap.php
<?php
class SiteMap {
	var $pages = array();
	var $file;
	function SiteMap($file) {
		$this->file = $file;
	}
	function create()
	{
		$str = $this->xmlHeader();
		$str .= $this->getPages();
		$str .= $this->xmlFooter();
		$this->write2file($this->file, $str);
		die('Done! <a href="'.$this->file.'">SiteMap</a>');
	}
	function xmlHeader()
	{
		$str = '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
		return $str;
	}
	function xmlFooter()
	{
		$str = '
		</urlset>
		';
		return $str;
	}
	function getPages()
	{
		for ($i = 0; $i < count($this->pages['url']); $i ++){
			$str .= '
			<url>
				<loc>'.$this->pages['url'][$i].'</loc>
				<lastmod>'.date('Y-m-d').'T'.date('H:i:s').'+00:00</lastmod>
				<changefreq>'.$this->pages['frecvent'][$i].'</changefreq>
				<priority>'.$this->pages['priority'][$i].'</priority>
			</url>
			';
		}
		return $str;
	}
	function addPage($url, $frecvent = 'daily', $priority = 1.0)
	{
		$this->pages['url'][] = $url;
		$this->pages['frecvent'][] = $frecvent;
		$this->pages['priority'][] = $priority;
	}
	function write2file($fname, $string)
	{
		@unlink($fname);
		@file_put_contents($fname, $string);
	}
}
?>
Return current item: Google SiteMap generator