Save it as sitemap. asp and put it under the root directory of the website. Set the name of the folder to be generated and run the command.
<%
'Sitemap. asp
Session ("count") = 0
'Your Domain Name
Session ("server") = "http: // your website address"
'Create a directory for generating sitemap. XML, Which is case sensitive and does not contain "/".
Vdir = "/XXXXX"
'Set the file name extension you want to include in Google
Extensions = array ("PNG", "GIF", "jpg", "Jpeg", "Zip", "pdf", "Ps", "html", "htm ", "asp", "php", "wk1", "WK2", "wk3", "wk4", "wk5", "wki", "wks", "wku ", "lwp", "MW", "xls", "ppt", "Doc", "SWF", "wks", "WPS", "wdb", "WRI ", "rtf", "Ans", "TXT", "shtml", "SHTM ")
'Directory to be filtered
Pathexclusion = array ("\ ADMIN", "\ _ vti_cnf", "_ vti_pvt", "_ vti_log", "cgi-bin", "aspnet_client ")
Set objfso = Createobject ("scripting. FileSystemObject ")
Root = server. mappath (vdir)
'Response. End
'Create a file
Objfso. createtextfile (server. mappath ("/sitemap. xml "))
Response. Write "<p> <strong style = 'font-family: Arial, sans-serif; font-size = 12'> sitemap. XML is created successfully! </Strong> <I style = 'font-family: Arial, sans-serif; font-size = 12'> "& server. mappath ("/sitemap. XML ") &" </I> </P>"
Response. write "<p> <strong style = 'font-family: Arial, sans-serif; font-size = 12'> the file is being indexed. Please wait... </strong> </P>"
Set openfileobj = objfso. opentextfile (server. mappath ("/sitemap. xml"), 8)
Openfileobj. writeline "<? XML version = '1. 0' encoding = 'utf-8'?> "
Openfileobj. writeline "<urlset xmlns = 'HTTP: // www.google.com/schemas/sitemap/0.84'>"
Set objfolder = objfso. getfolder (Root)
Set colfiles = objfolder. Files
For each objfile in colfiles
Openfileobj. writeline getfilelink (objfile. Path, objfile. datelastmodified)
Next
Showsubfolders (objfolder)
Openfileobj. writeline "</urlset>"
Response. write "<p> <strong style = 'font-family: Arial, sans-serif; font-size = 12'> sitemap. XML generation is complete. <span style = color: # ff0000> "& SESSION (" count ") & "</span> files are indexed </strong> </P>"
Set FSO = nothing
Sub showsubfolders (objfolder)
Set colfolders = objfolder. subfolders
For each objsubfolder in colfolders
If folderpermission (objsubfolder. Path) then
Openfileobj. writeline getfilelink (objsubfolder. Path, objsubfolder. datelastmodified)
Set colfiles = objsubfolder. Files
For each objfile in colfiles
Openfileobj. writeline getfilelink (objfile. Path, objfile. datelastmodified)
Next
Showsubfolders (objsubfolder)
End if
Next
End sub
Function getfilelink (file, datafile)
File = Replace (file, root ,"")
File = Replace (file ,"\","/")
If fileextensionisbad (File) Then exit function
If month (datafile) <10 then filedatem = "0"
If Day (datafile) <10 then filedated = "0"
Filedate = year (datafile) & "-" & filedatem & month (datafile) & "-" & filedated & Day (datafile)
Getfilelink = "<URL>" & CHR ("10") & "<loc>" &server.html encode (Session ("server") & vdir & file) & "</loc>" & CHR ("10") & "<lastmod>" & filedate & "</lastmod>" & CHR ("10 ") & "<changefreq> daily </changefreq>" & CHR ("10") & "<priority> 1.0 </Priority>" & CHR ("10 ") & "</URL>"
Session ("count") = SESSION ("count") + "1"
Response. Flush
End Function
Function folderpermission (pathname)
Folderpermission = true
For each pathexcluded in pathexclusion
If instr (ucase (pathname), ucase (pathexcluded)> 0 then
Folderpermission = false
Exit
End if
Next
End Function
Function fileextensionisbad (sfilename)
Dim sfileextension, bfileextensionisvalid, sfileext
If Len (TRIM (sfilename) = 0 then
Fileextensionisbad = true
Exit Function
End if
Sfileextension = right (sfilename, Len (sfilename)-limit Rev (sfilename ,"."))
Bfileextensionisvalid = false
For each sfileext in extensions
If ucase (sfileext) = ucase (sfileextension) then
Bfileextensionisvalid = true
Exit
End if
Next
Fileextensionisbad = Not bfileextensionisvalid
End Function
%>