файл xml.php
CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?php
- header('Content-type: text/xml; charset=utf-8');
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- include('db.php');
- $xml='<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">';
- $xml.="<url>
- <loc>http://www.test.com/</loc>
- <changefreq>daily</changefreq>
- <priority>0.8</priority>
- </url>";
- $sql_art = 'select * from articles where static = 0 order by title limit 100';
- $query_art = mysql_query($sql_art);
- while ($row_art = mysql_fetch_assoc($query_art))
- {
- $xml.="<url>
- <loc>http://www.test.com/".$row_art['title_url'].".html</loc>
- <lastmod>".$row_art['add_date']."</lastmod>
- <changefreq>weekly</changefreq>
- <priority>0.8</priority>
- </url>";
- }
- $xml.='<urlset>';
- echo $xml;
- ?>