Sitemap file creator from local copy of file

Computer Repair
Central
Contact Me
email:
 
Anoox community portal

Sitemaps

Sitemaps are a way to tell the major search engine about all of the pages in your website. Sitemaps can be produced in a number of different formats, but the XML format allows additional information to be entered with the Sitemap. The XML sitemap is of the form:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.computerrepaircentral.com.au/computerwillnotstart.php</loc>
<lastmod>2008-04-25</lastmod>
<changefreq>Weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
Sitemaps are particularly an advantage for sites that use forms to move between pages within a site. Normally search engine bots will not be able to follow the form links correctly. In any case, the sitemap format helps the search engine to understand your site better and that can only be a good thing. Once the sitemap is created it can be manually submitted to each search engine or it can be included in the robots.txt file with the line
Sitemap: http://www.example.tld/sitemap.xml
There are many programs that will automatically create a sitemap.xml file from your website but after trying a few programs I wrote a quick VBA version for myself. This version works on the local project rather than from the website. Put it into any Microsoft program that will run VBA.
Const LocalDirectory = &quot;C:\Users\janosm\Documents\My Web Sites\computer\&quot;
Const Domain = &quot;http://www.computerrepaircentral.com.au/&quot;


Sub main()
Dim oFso As New FileSystemObject
Dim oFolder As Folder

Open LocalDirectory &amp; &quot;sitemap.xml&quot; For Output As #1

Set oFolder = oFso.GetFolder(LocalDirectory)
Print #1, &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;UTF-8&quot;&quot;?&gt;&quot;
Print #1, &quot;&lt;urlset xmlns=&quot;&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&quot;&gt;&quot;


OutputFiles oFolder, oFso


Print #1, &quot;&lt;/urlset&gt;&quot;
Close #1
End Sub

Sub OutputFiles(oFolder As Folder, oFso As FileSystemObject)
Dim oFile As File
Dim oSubFolder As Folder
Dim ext As String
Dim path As String
For Each oFile In oFolder.Files
ext = oFso.GetExtensionName(oFile.path)
If InStr(&quot;html,htm,php&quot;, LCase(ext)) &lt;&gt; 0 Then
path = Replace(oFile.path, LocalDirectory, URL)
path = Replace(path, &quot;\&quot;, &quot;/&quot;)
Print #1, &quot; &lt;url&gt;&quot;
Print #1, &quot; &lt;loc&gt;&quot;; path; &quot;&lt;/loc&gt;&quot;
Print #1, &quot; &lt;lastmod&gt;&quot;; Format(oFile.DateLastModified, &quot;yyyy-mm-dd&quot;); &quot;&lt;/lastmod&gt;&quot;
Print #1, &quot; &lt;changefreq&gt;Weekly&lt;/changefreq&gt;&quot;
Print #1, &quot; &lt;priority&gt;0.5&lt;/priority&gt;&quot;
Print #1, &quot; &lt;/url&gt;&quot;
End If
Next oFile

For Each oSubFolder In oFolder.SubFolders
If InStr(oSubFolder.Name, &quot;_vti_cnf&quot;) = 0 And InStr(oSubFolder.Name, &quot;reports&quot;) = 0 Then
OutputFiles oSubFolder, oFso
End If
Next oSubFolder

End Sub



				

In the references section select the Microsoft Scripting Runtime. This allows the filesystemobject object which is used for iterating through the folders.
All you need to do to the code is change the constants in the first two lines to point to the folder that contains the web project for your site and the target web site. Run the program and it will create a file called sitemap.xml in the root directory of your project.
Computer Troubleshooters Nowra
If you need a professional computer technician


Computer Repair Central
Power problems for your PC
Computer will not start
How to get a Search Engine to find you
Automatically create a Sitemap for a Search Engine