Hi:
I want to make a dynamic sitemap . this is my code that was written with class
but show this error:
This page contains the following errors:
error on line 2 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
<?php
class googlemap{
var $home = patch_url;
var $limit = 10;
var $news_priority = "0.5";
var $stat_priority = "0.5";
var $priority = "0.6";
var $cat_priority = "0.7";
function googlemap () {
}
function build_map () {
$map = "<?xml version='1.0' encoding='UTF-8'?><urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
$map .= $this->get_static();
$map .= "</urlset>";
return $map;
}
function get_static() {
global $class_db;
if ($this->limit < 1) $this->limit = false;
if ($this->limit) {
$this->limit = " LIMIT 0,".$this->limit;
} else {
$this->limit = "";
}
$xml = "";
$lastmod=date("Y-m-d");
$this->priority = $this->stat_priority;
$my_sql_info = $class_db->sql_query("SELECT * FROM `".dbperfix."page_name` ORDER BY `id` DESC ".$this->limit ."");
$n=0;
while($my_sql_info_r = $class_db->sql_fetchrow( $my_sql_info ) ){
$loc = $this->home.'/fa/fullmode/page/'.$my_sql_info_r['url'].'.html';
$xml .= $this->get_xml($loc, $lastmod);
}
return $xml;
}
function get_xml($loc, $lastmod){
$loc = htmlspecialchars($loc);
$xml = "\t<url>\n";
$xml .= "\t\t<loc>$loc</loc>\n";
$xml .= "\t\t<lastmod>$lastmod</lastmod>\n";
$xml .= "\t\t<priority>".$this->priority."</priority>\n";
$xml .= "\t</url>\n";
return $xml;
}
}
?>