Всем привет, для поисковиков пытаюсь сгенерировать xml при помощи php.
файл 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; ?>
Выводит ошибку
This page contains the following errors:
error on line 1 at column 50: AttValue: " or ' expected
Below is a rendering of the page up to the first error.
Пробелов перед и после <?php нету
(Добавление)
Изменил на header('Content-type: application/xml'); все заработало(Отредактировано автором: 01 Октября, 2014 - 10:01:32)
|