<! #include file= conn asp >
<%
session( count )=
strURL = // & request servervariables( SERVER_NAME ) & _
left(request servervariables( SCRIPex ) len(request servervariables( SCRIPex )) len( /sitemap asp ))
dim foolcat
foolcat = foolcat + <?xml version= encoding= UTF ?>
foolcat = foolcat + <! Google Site Map File Generated by & return_RFC _Date(now GMT ) & >
foolcat = foolcat + <urlset xmlns= >
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & /</loc>
foolcat = foolcat + </url>
session( count )=session( count )+
set all_fs = Server CreateObject( Scripting FileSystemObject )
set all_folder = all_fs GetFolder(server MapPath( / ))
set all_files = all_folder files
for each file in all_files
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & / & File Name & </loc>
foolcat = foolcat + </url>
session( count )=session( count )+
next
dim js sql
set js = server CreateObject( ADODB RecordSet )
sql = select * from [要生成的表名] order by sid asc 修改你要生成的數據表名
set js = conn execute (sql)
do until js eof
id= &js( id )& 修改為你的id字段
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & /xxx asp?Id= & id & </loc> 修改為你的文件名稱和id
foolcat = foolcat + </url>
session( count )=session( count )+
js movenext
loop
js close
set js = nothing
foolcat = foolcat + </urlset>
foolcat = + foolcat +
foolcat = & foolcat &
FolderPath = Server MapPath( / )
Set fso = Server CreateObject( Scripting FileSystemObject )
Set fout = fso CreateTextFile(FolderPath& \sitemap xml )
fout writeLine foolcat
fout close
set fout = nothing
conn close
set conn = nothing
Function return_RFC _Date(byVal myDate byVal TimeZone)
Dim myDay myDays myMonth myYear
Dim myHours myMinutes mySeconds
myDate = CDate(myDate)
myDay = EnWeekDayName(myDate)
myDays = Right( & Day(myDate) )
myMonth = EnMonthName(myDate)
myYear = Year(myDate)
myHours = Right( & Hour(myDate) )
myMinutes = Right( & Minute(myDate) )
mySeconds = Right( & Second(myDate) )
return_RFC _Date = myDay& & _
myDays& & _
myMonth& & _
myYear& & _
myHours& : & _
myMinutes& : & _
mySeconds& & _
& TimeZone
End Function
Function EnWeekDayName(InputDate)
Dim Result
Select Case WeekDay(InputDate )
Case :Result= Sun
Case :Result= Mon
Case :Result= Tue
Case :Result= Wed
Case :Result= Thu
Case :Result= Fri
Case :Result= Sat
End Select
EnWeekDayName = Result
End Function
Function EnMonthName(InputDate)
Dim Result
Select Case Month(InputDate)
Case :Result= Jan
Case :Result= Feb
Case :Result= Mar
Case :Result= Apr
Case :Result= May
Case :Result= Jun
Case :Result= Jul
Case :Result= Aug
Case :Result= Sep
Case :Result= Oct
Case :Result= Nov
Case :Result= Dec
End Select
EnMonthName = Result
End Function
%>
sitemap xml生成完畢 共生成<%=session( count )%>個文件 點擊查看<a >sitemap xml</a>文件
From:http://tw.wingwit.com/Article/program/net/201311/12231.html