Write a SiteMap.php script that will generate Sitemap.xml

There is a task – Write a SiteMap.php script that will generate a site map, type, sitemap.xml.

Sitemap.xml standard file view:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
#     #

inside tags & lt; urlset & gt; & lt; / urlset & gt; We need to withdraw all pages of the site http://www.tehnodar.kh.ua/. For example:


and so on, bring all page pages.

Tell me, please, the writing algorithm for this PHP script, without connecting to the MySQL database. Thanks in advance.

There is an idea to try this:

(array)$site = scandir("http://www.tehnodar.kh.ua/");
$fp = fopen("sitemap.xml", "w");
fputs($fp, $site);

is a super simplified version, tell me, does he have the right to life? If the elements of the $ SITE array elements go through $ Site [i] cycle, how are they then saved to the SiteMap.xml file?

Answer 1, Authority 100%

Your idea is crazy 🙂
You are trying to open HTML text (it is his function) as a directory.

There is Script , which makes what you want.

In general, the connection to MySQL may be needed in order to speed up the process of generating a site map. If you have a less static site with a pair of hundreds of articles – you can not bother.