您当前的位置: 首页 > 网站编程 > ASP教程 > asp生成google网站地图的xml源代码

asp生成google网站地图的xml源代码

作者:不详 来源:网络 发布时间: 2011-06-15 13:41 点击:
% Response.Buffer = True With Response .Expires = -1 .AddHeader Pragma,no-cache .AddHeader cache-ctrol,no-cache End With % % Server.ScriptTimeout=50000 Dim str,objStream str = ?xml version='1.0' encoding='UTF-8'? vbcrlf str = str urlset xmlns='http:

asp生成google网站地图的xml源代码

<%
Response.Buffer = True
With Response
 .Expires = -1
 .AddHeader "Pragma","no-cache"
 .AddHeader "cache-ctrol","no-cache"
End With
%>
<%
Server.ScriptTimeout=50000

Dim str,objStream
str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" & vbcrlf
str = str & getfilelink & vbcrlf
str = str & "</urlset>" & vbcrlf

Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "UTF-8"
.Position = objStream.Size
.WriteText=str
.SaveToFile server.mappath("sitemap.xml"),2
.Close
End With
Set objStream = Nothing

If Not Err Then
   Response.Redirect("sitemap.xml")
   Response.End
End If

Function getfilelink()
   SQL="SELECT * FROM 表名 ORDER BY id DESC"
   Dim RS
   Set RS=Server.CreateObject("ADODB.RecordSet")
   RS.Open SQL,Conn,1,1

   IF RS.EOF AND RS.BOF Then
      Response.Write("<url></url>")
   Else
      Do While NOT RS.EOF
   Y=year(RS("intime"))
   if len(month(RS("intime")))=1 then
   M=0&month(RS("intime"))
   else
   M=month(RS("intime"))
   end if
   if len(day(RS("intime")))=1 then
   D=0&day(RS("intime"))
   else
   D=day(RS("intime"))
   end if
          getfilelink = getfilelink & "<url><loc>http://www.mycodes.net/html/"&RS("Classid")&"/"&RS("ID")&".Html</loc><lastmod>"&Y&"-"&M&"-"&D&"</lastmod><changefreq>"&RS("Title")&"</changefreq><priority>1.0</priority></url>"
          RS.MoveNext
      Loop
   End IF
RS.Close
Set RS=Nothing
Conn.Close
Set Conn=Nothing
End Function
%>

分享到:
本文"asp生成google网站地图的xml源代码"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4