ѡ⣺
ʵxml漼webվ
xml漼ݿѹ
xml

ؼʣxml,webվ,ݿѹ,xml

ģ

һȶwebվһֱվͳԱ룬ߵһ˵˵xml漼ʵվĸܡ
Ǵӽ꿪ʼ138ֻģSQL2000Ϊݿ⣬õAspѯʱǶ̬ѯֱlike %ķʽǸʱһķСͬʱߵʱҲͼʮ˶ѣԷҲʤҪŷӣͬʱߴﵽʱʱʼظCPUﵽ100%ҳٶҲһѯҳҪҿʼŻݿ⣬ݿ⽨Ǻ룬Ϊõlike '% ַʽ뵽˻棬xmlصǳʺݿĻ棬öҶطԱͬнͬ
ʵֵ˼·ģȡϢʱжǷ񻺴xmlݣУֱӴxmlжȡϢݿжȡ˴νxmlļԱԺãӿٶȣͬʱжxmlļǷڣҪxmlǾĴ롣

xmlcachecls.asp
<%
Rem xmlݻ
'--------------------------------------------------
'תصʱ뱣ȨϢ
':walkman
'ַ:ֻ http://www.shouji138.com
'汾:ver1.0
'ӭλ
'--------------------------------------------------

Class XmlCacheCls

	Rem ˽б
	Private m_CacheTime		'ʱ䣬λ
	Private m_PageSize		'ÿҳС
	Private m_CachePageNum	'xmlҳС
	Private m_XmlFile		'xml·þԵַ,Ҫչ
	Private m_Sql			'SQL
	Private m_TableName		'ͼ
	Private m_Columns		' ,
	Private m_CurPage		'ǰҳ
	Private m_CacheType		'ͣ1,б 2,
	Private m_DataConn		'Դ,Ѿ
	Private m_QueryType		'ѯͣ1,ֱsql 2,ô洢

	Private m_SQLArr		'ص
	Private m_RecordCount
	
	
	Rem 

	'ʱ
	Public Property Let  CacheTime(v)
		m_CacheTime = v 
	End Property

	Public Property Get  CacheTime
		CacheTime = m_CacheTime 
	End Property

	
	'ÿҳС
	Public Property Let  PageSize(v)
		m_PageSize = v 
	End Property

	Public Property Get  PageSize
		PageSize = m_PageSize 
	End Property



	'xmlҳС
	Public Property Let  CachePageNum(v)
		m_CachePageNum = v 
	End Property

	Public Property Get  CachePageNum
		CachePageNum = m_CachePageNum 
	End Property



	'xml·þԵַ
	Public Property Let  XmlFile(v)
		m_XmlFile = v 
	End Property

	Public Property Get  XmlFile
		XmlFile = m_XmlFile 
	End Property


	'xml·þԵַ
	Public Property Let  Sql(v)
		m_Sql = v 
	End Property

	Public Property Get  Sql 
		Sql = m_Sql 
	End Property


	'ͼ
	Public Property Let  TableName(v)
		m_TableName = v 
	End Property

	Public Property Get  TableName 
		TableName = m_TableName 
	End Property



	' ,
	Public Property Let  Columns(v)
		m_Columns = v 
	End Property

	Public Property Get  Columns 
		Columns = m_Columns 
	End Property

	
	'ǰҳ
	Public Property Let  CurPage(v)
		m_CurPage = v 
	End Property

	Public Property Get  CurPage 
		CurPage = m_CurPage 
	End Property


	
	'ͣ1,б 2,
	Public Property Let  CacheType(v)
		m_CacheType = v 
	End Property

	Public Property Get  CacheType 
		CacheType = m_CacheType 
	End Property



	'ͣ1,б 2,
	Public Property Set  Conn(v)
		Set m_DataConn = v 
	End Property

	Public Property Get  Conn 
		Conn = m_DataConn 
	End Property


	'ؼ¼
	Public Property Get  RecordCount 
		RecordCount = m_RecordCount 
	End Property

	'ؼ¼
	Public Property Get  SQLArr 
		SQLArr = m_SQLArr 
	End Property


	Rem  ȡ
	Public Function ReadData
		If m_CacheType = 1 Then 
			ReadListAndSearchData
		Else 
			ReadContentData
		End If 
	End Function 
	
	Rem ȡϢ
	Private Function ReadContentData
		Dim xmlfile
		xmlfile = m_XmlFile
		If FSOExistsFile(xmlfile) Then	'xml棬ֱӴxmlжȡ
			ReadContentDataFromXml xmlfile
		Else
			ReadContentDataFromDB
		End If 
	End Function 
	
	Rem xmlļȡϢ
	Private Function ReadContentDataFromXml(xmlfile)
		Dim SQLARR()
		Dim XmlDoc
		Set XmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0")
		XmlDoc.Load xmlfile 
		Dim itemslength,itemsi
		itemslength = XmlDoc.documentElement.childNodes.length

		For itemsi=0 To itemslength-1
			ReDim Preserve SQLARR(itemslength-1,0)
			SQLARR(itemsi,0) = XmlDoc.documentElement.childNodes(itemsi).text
		Next 
		Set XmlDoc = Nothing 
		m_SQLArr = SQLArr
	End Function 
	

	Rem DbжȡϢ
	Private Function ReadContentDataFromDB()
		Dim rs
		Dim SQLARR
		Set rs = m_DataConn.execute(m_sql)
		IF Not Rs.eof Then
			SQLArr=Rs.GetRows(1)
			rs.close
			Set rs = Nothing
		Else
			rs.close
			Set rs = Nothing
			Exit Function 
		End If 
		m_SQLArr = SQLArr
	End Function 


	Rem ȡб
	Private Function ReadListAndSearchData
		Dim sPagesize,TotalPage,CurPage,TotalRec
		sPagesize = m_PageSize * m_CachePageNum

		m_CurPage = CLng(m_CurPage)
		
		If m_CurPage Mod m_CachePageNum = 0 Then 
			CurPage = m_CurPage/m_CachePageNum
		Else
			CurPage = int(clng(m_CurPage)/m_CachePageNum)+1
		End If 

		Dim xmlfile
		xmlfile = getXmlFileName(CurPage)
		If FSOExistsFile(xmlfile) Then	'xml棬ֱӴxmlжȡ
			ReadListAndSearchDataFromXml xmlfile
		Else
			ReadListAndSearchDataFromDB
		End If 
	End Function 

	Rem xmlжб
	Private Function ReadListAndSearchDataFromXml(xmlfile)
		Dim SQLARR()
		Dim XmlDoc
		Set XmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0")
		XmlDoc.Load xmlfile 
		Dim totalrecont
		totalrecont = XmlDoc.documentElement.selectSingleNode("totalrec").text
		m_RecordCount = totalrecont
		Dim TotalRec
		TotalRec = m_RecordCount
		If totalrecont = 0 Then 
			Set XmlDoc = Nothing
			m_SQLArr = SQLARR
			Exit Function 
		End If 

		Dim TotalPage,curpage
		curpage = m_CurPage
		If m_CurPage Mod m_CachePageNum = 0 Then 
			CurPage = m_CurPage/m_CachePageNum
		Else
			CurPage = int(clng(m_CurPage)/m_CachePageNum)+1
		End If 

		If TotalRec Mod m_CachePageNum =0 Then 
			TotalPage = totalrecont/m_CachePageNum
		Else
			TotalPage = int(clng(totalrecont)/m_CachePageNum)+1
		End If 
		
		If curpage>TotalPage Then curpage=TotalPage
		Dim starti
		Dim startn
		startn = m_curpage - (curpage-1) * m_CachePageNum
		Rem 㿪ʼλ
		starti = (startn-1) * m_pagesize
		Dim items,item
		Set items = XmlDoc.documentElement.SelectNodes("item")
		Dim i
		Dim num
		Dim length
		length = items.length
		num = 0
		For i = starti To m_PageSize + starti -1
			If i >=length Then Exit For 
			Set item = items(i)
			Dim attrlength
			attrlength = item.attributes.length
			ReDim Preserve SQLARR(attrlength,num)
			Dim Attribute
			Dim Attributei
			Attributei = 0
			For Attributei = 0 To attrlength-1
				SQLArr(Attributei,num) = item.attributes(Attributei).Nodevalue
			Next 		
			num = num + 1
		Next 
		Set XmlDoc = Nothing 
		m_SQLArr = SQLArr
	End Function 
	
	Rem DBжб
	Private Function ReadListAndSearchDataFromDB
		Dim rs,TotalRec,CurPage
		CurPage = m_CurPage
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Rs.open m_sql,m_DataConn,1
		TotalRec = rs.recordcount
		m_RecordCount = TotalRec
		rs.pagesize = m_PageSize
		If  CurPage>rs.PageCount Then  CurPage = rs.PageCount
		If Not rs.eof Then rs.absolutePage=m_CurPage
		Dim SQLARR()
		Dim k
		k = 0
		While Not rs.eof and k<m_PageSize
			Dim fieldlegth
			fieldlegth = rs.Fields.count
			ReDim Preserve SQLARR(fieldlegth,k)
			
			Dim fieldi
			For fieldi = 0 To fieldlegth-1
				SQLArr(fieldi,k) = rs.Fields(fieldi).value
			Next 
			rs.movenext
			k=k+1
		Wend 
		rs.close
		Set rs = Nothing 
		m_SQLArr = SQLArr
	End Function 


	Rem ȡxmlļ
	Private Function getXmlFileName(num)
		Dim tmpstr
		tmpstr = LCase(m_XmlFile)
		If Right(tmpstr,4) = ".xml" Then
			tmpstr = Left(tmpstr,Len(tmpstr)-Len(".xml"))
		End If 
		tmpstr = Replace(tmpstr,"%","_")
		tmpstr = tmpstr & "_" & num & ".xml"
		getXmlFileName = tmpstr
	End Function 

	
	Rem  дxmlļ
	Public Function WriteDataToXml
		If m_CacheType = 1 Then 
			WriteListAndSearchDataToXml
		Else 
			WriteContentDataToXml
		End If 
	End Function 


	Rem дĳϢxml
	Private Function WriteContentDataToXml
		Rem xmlδֱ˳
		Dim xmlfile
		xmlfile = m_XmlFile
		If FSOExistsFile(xmlfile) Then
			If Not isXmlCacheExpired(xmlfile,m_CacheTime) Then  Exit Function 
		End If 
		Dim rs
		Set rs = Server.CreateObject("Adodb.Recordset")

		Rs.open m_sql,m_DataConn
		CreateContentXmlFile xmlfile,Rs 
	End Function 


	Rem бxml
	Private Function WriteListAndSearchDataToXml
		
		Dim sPagesize,TotalPage,CurPage,TotalRec
		sPagesize = m_PageSize * m_CachePageNum

		m_CurPage = CLng(m_CurPage)
		
		If m_CurPage Mod m_CachePageNum = 0 Then 
			CurPage = m_CurPage/m_CachePageNum
		Else
			CurPage = int(clng(m_CurPage)/m_CachePageNum)+1
		End If 

		Dim xmlfile
		xmlfile = getXmlFileName(CurPage)

		Rem xmlδֱ˳
		If FSOExistsFile(xmlfile) Then
			If Not isXmlCacheExpired(xmlfile,m_CacheTime) Then  Exit Function 
		End If
		Dim rs
		Set Rs = Server.CreateObject("Adodb.Recordset")
		Rs.open m_sql,m_DataConn,1
		TotalRec = rs.recordcount
		rs.pagesize = sPagesize
		If  CurPage>rs.PageCount Then  CurPage = rs.PageCount
		CreateListAndSearchXMLFile xmlfile,TotalRec,Rs,sPagesize
	End Function 



	Rem ˽з
	Rem õļ޸ʱ
	Private Function FSOGetFileLastModifiedTime(file)
		Dim fso,f,s   
		Set fso=CreateObject("Scripting.FileSystemObject")   
		Set f=fso.GetFile(file)   
		FSOGetFileLastModifiedTime = f.DateLastModified
		Set f = Nothing
		Set fso = Nothing 
	End Function 


	Rem жxmlǷ
	Private Function isXmlCacheExpired(file,seconds)
		Dim filelasttime
		filelasttime = FSOGetFileLastModifiedTime(file)
		If DateAdd("s",seconds,filelasttime) < Now Then
			isXmlCacheExpired = True 
		Else
			isXmlCacheExpired = False
		End If 
	End Function

	Rem ļǷ
	Private Function FSOExistsFile(file)
		Dim fso
		Set fso = Server.CreateObject("Scripting.FileSystemObject")
		If fso.FileExists(file) Then
			FSOExistsFile = true
		Else
			FSOExistsFile = false
		End If 
		Set fso = nothing
	End Function 
	

	Rem ϸݵxml
	Private Function CreateContentXmlFile(xmlfile,Rs)
		Dim xmlcontent
		xmlcontent = "<?xml version=""1.0"" encoding=""gb2312""?>" & vbnewline
		xmlcontent = xmlcontent & "<root>" & vbnewline
		
		Dim field
		For Each field In rs.Fields
			xmlcontent = xmlcontent & "<"&field.name&">"
			Dim value
			value = field.value
			If TypeName(value) = "String" Then 
				xmlcontent = xmlcontent & "<![CDATA[" & Trim(value) & "]]>"
			Else
				xmlcontent = xmlcontent &  Trim(value) 
			End If 
			xmlcontent = xmlcontent & "</"&field.name&">" & vbnewline
		Next 
		rs.close
		Set rs = Nothing 
		xmlcontent = xmlcontent & "</root>" & vbnewline
		
		Dim folderpath
		folderpath = Trim(left(xmlfile,InstrRev(xmlfile,"\")-1))
		Call CreateDIR(folderpath&"") 'ļ
		WriteStringToXMLFile xmlfile,xmlcontent	
	End Function 


	Rem бxml
	Private Function CreateListAndSearchXMLFile(xmlfile,TotalRec,Rs,sPagesize)
		Dim xmlcontent
		xmlcontent = ""
		xmlcontent = xmlcontent & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbnewline
		xmlcontent = xmlcontent & " <root>" & vbnewline
		xmlcontent = xmlcontent & "  <totalrec>" & TotalRec & "</totalrec>" & vbnewline

		Dim k
		k = 0
		Dim field
		While Not rs.eof and k<sPagesize
			xmlcontent = xmlcontent & "  <item "
			For Each field In rs.Fields
				xmlcontent = xmlcontent & field.name & "=""" & XMLStringEnCode(field.value) & """ "
			Next 
			xmlcontent = xmlcontent &  "></item>" & vbnewline
			rs.movenext
			k=k+1
		Wend 
		rs.close
		Set rs = Nothing 
		xmlcontent = xmlcontent & " </root>" & vbnewline
		Dim folderpath
		folderpath = Trim(left(xmlfile,InstrRev(xmlfile,"\")-1))
		Call CreateDIR(folderpath&"") 'ļ
		WriteStringToXMLFile xmlfile,xmlcontent
	End Function 

	Rem xmlתַ
	Private Function XMLStringEnCode(str)
		If str&"" = "" Then XMLStringEnCode="":Exit Function
		str = Replace(str,"<","&lt;")
		str = Replace(str,">","&gt;")
		str = Replace(str,"'","&apos;")
		str = Replace(str,"""","&quot;")
		str = Replace(str,"&","&amp;")
		XMLStringEnCode = str
	End Function 
	Rem дļ
	Private Sub WriteStringToXMLFile(filename,str)
		'On Error Resume Next 
		Dim fs,ts
		Set fs= createobject("scripting.filesystemobject")
		If Not IsObject(fs) Then Exit Sub 		
		Set ts=fs.OpenTextFile(filename,2,True)
		ts.writeline(str)
		ts.close
		Set ts=Nothing
		Set fs=Nothing
	End Sub 


	Rem ļ
	Private function CreateDIR(byval LocalPath)
		On  Error  Resume  Next 
		Dim i,FileObject,patharr,path_level,pathtmp,cpath
		LocalPath = Replace(LocalPath,"\","/")
		Set  FileObject = server.createobject("Scripting.FileSystemObject")
		patharr = Split(LocalPath,"/")
		path_level = UBound (patharr)
		For  i = 0 To  path_level
			If  i=0 Then  
				pathtmp=patharr(0) & "/" 
			Else  
				pathtmp = pathtmp & patharr(i) & "/"
			End If 
			cpath = left(pathtmp,len(pathtmp)-1)
			If  Not  FileObject.FolderExists(cpath) Then 
				'Response.write cpath
				FileObject.CreateFolder cpath
			End  If 
		Next 
		Set  FileObject = Nothing 
		If  err.number<>0 Then 
			CreateDIR = False 
			err.Clear
		Else 
			CreateDIR = True 
		End  If 
	End  Function 
End Class 
%>


ֻ淽ʽһǻбʽģ簴ĳʾϢĳؼʽʾһϸҳĻ棬ʾĳƪ¡
ҵ߼޹أֻxmlݵĶȡʹ洢жǷ񻺴ھǷҪ»档㹹ģʽĻݷʲ㡣


Ĵ룺
Business.asp
<%
Rem xmlݻҵ߼
'--------------------------------------------------
'תصʱ뱣ȨϢ
':walkman
'ַ:ֻ http://www.shouji138.com
'汾:ver1.0
'ӭλ
'--------------------------------------------------

Rem classidȡб
Function GetListarr(classid,curpage,PageSize,CachePageNum,ByRef RecordCount)
	openConn
	Dim sql
	sql = "select thmid,thmname,picfileurl,win_theme.adddate from win_theme where  win_theme.ClassID="&classid&" order by thmid desc"
	Dim cache
	Set cache = new XmlCacheCls
	cache.PageSize = PageSize			  'ÿҳN¼
	cache.CachePageNum = CachePageNum		  'һxmlļMҳ
	cache.XmlFile = Server.Mappath("xmlcache/classxml/list_"&classid&".xml")
	cache.Sql = sql
	cache.CurPage = curpage
	cache.CacheType = 1
	Set cache.Conn = conn	
	cache.ReadData
	Dim SqlArr
	SQLArr = cache.SQLArr
	RecordCount = cache.RecordCount
	Set cache = Nothing 
	GetListarr = SqlArr
End Function 


Rem classidxml
Function CreateListxml(classid,curpage,PageSize,CachePageNum,CacheTime)
	Dim sql
	sql = "select thmid,thmname,picfileurl,win_theme.adddate from win_theme where  win_theme.ClassID="&classid&" order by thmid desc"
	Dim cache
	Set cache = new XmlCacheCls
	cache.CacheTime = CacheTime 'ʱ
	cache.PageSize = PageSize			  'ÿҳN¼
	cache.CachePageNum = CachePageNum		  'һxmlļMҳ
	cache.XmlFile = Server.Mappath("xmlcache/classxml/list_"&classid&".xml")
	cache.Sql = sql
	cache.CurPage = curpage
	cache.CacheType = 1
	Set cache.Conn = conn
	cache.WriteDataToXml
	Set cache = Nothing 
End Function 


Rem keywordȡб
Function GetSearcharr(keyword,curpage,PageSize,CachePageNum,ByRef RecordCount)
	openConn
	Dim sql
	Dim sqlkey
	sqlkey = Replace(keyword,"'","")
	sql = "select thmid,thmname,picfileurl,win_theme.adddate from win_theme where  ThmName like '%"&sqlkey&"%' or ThmRange  like '%"&sqlkey&"%' or ThmInstro  like '%"&sqlkey&"%'  order by thmid desc"
	Dim cache
	Set cache = new XmlCacheCls
	cache.PageSize = PageSize			  'ÿҳN¼
	cache.CachePageNum = CachePageNum		  'һxmlļMҳ
	cache.XmlFile = Server.Mappath("xmlcache/searchxml/list_"&Server.URlEncode(Replace(keyword,"'",""))&".xml")
	cache.Sql = sql
	cache.CurPage = curpage
	cache.CacheType = 1
	Set cache.Conn = conn	
	cache.ReadData
	Dim SqlArr
	SQLArr = cache.SQLArr
	RecordCount = cache.RecordCount
	Set cache = Nothing 
	GetSearcharr = SqlArr
End Function 



Rem keywordxml
Function CreateSearchxml(keyword,curpage,PageSize,CachePageNum,CacheTime)
	Dim sql
	Dim sqlkey
	sqlkey = Replace(keyword,"'","")
	sql = "select thmid,thmname,picfileurl,win_theme.adddate from win_theme where  ThmName like '%"&sqlkey&"%' or ThmRange  like '%"&sqlkey&"%' or ThmInstro  like '%"&sqlkey&"%'  order by thmid desc"
	Dim cache
	Set cache = new XmlCacheCls
	cache.CacheTime = CacheTime 'ʱ
	cache.PageSize = PageSize			  'ÿҳN¼
	cache.CachePageNum = CachePageNum		  'һxmlļMҳ
	cache.XmlFile =  Server.Mappath("xmlcache/searchxml/list_"&Server.URlEncode(Replace(keyword,"'",""))&".xml")
	cache.Sql = sql
	cache.CurPage = curpage
	cache.CacheType = 1
	Set cache.Conn = conn
	cache.WriteDataToXml
	Set cache = Nothing 
End Function 

Rem classidȡб
Function GetDetailarr(thmid)
	openConn
	Dim sql
	sql = "select a.thmid,a.thmname,a.classid,b.classname,a.picfileurl,a.thmver,a.thmsize,a.thminstro,a.thmrange,a.thmfileurl,a.adddate from win_theme a,Win_Classify b where a.classid=b.classid and  a.thmid="&thmid&""
	Dim thmidmod
	thmidmod = thmid Mod 100
	
	Dim cache
	Set cache = new XmlCacheCls
	cache.XmlFile = Server.Mappath("xmlcache/detailxml/"&thmidmod&"/"&thmid&".xml")
	cache.Sql = sql
	cache.CacheType = 2
	Set cache.Conn = conn	
	cache.ReadData
	Dim SqlArr
	SQLArr = cache.SQLArr
	Set cache = Nothing 
	GetDetailarr = SqlArr
End Function 

Rem keywordxml
Function CreateDetailxml(thmid,CacheTime)
	Dim sql
	sql = "select a.thmid,a.thmname,a.classid,b.classname,a.picfileurl,a.thmver,a.thmsize,a.thminstro,a.thmrange,a.thmfileurl,a.adddate from win_theme a,Win_Classify b where a.classid=b.classid and  a.thmid="&thmid&""
	Dim thmidmod
	thmidmod = thmid Mod 100
	Dim cache
	Set cache = new XmlCacheCls
	cache.CacheTime = CacheTime 'ʱ
	cache.XmlFile =  Server.Mappath("xmlcache/detailxml/"&thmidmod&"/"&thmid&".xml")
	cache.Sql = sql
	cache.CacheType = 2
	Set cache.Conn = conn
	cache.WriteDataToXml
	Set cache = Nothing 
End Function


Rem ⶯̬Ƿѷ
Function   ismalloc(a)
	On   Error Resume Next 
	Dim   i   
	i   =   UBound(a)
	If Err Then 
	ismalloc = False 
	Else
	ismalloc   =   True   
	End If  
End   Function  



Function showData(SQLArr)

	If Not  ismalloc(SQLArr) Then Exit Function 
	Dim i,k
	Dim num
	num = 0
	i = UBound(SQLArr,1)
	k = UBound(SQLArr,2)
	Dim m,n
	For m = 0 To k
		num = num+1
	%>	
 <ul class="listbox" onMouseOver="overtb(this)" onMouseOut="outtb(this)">
<li>
<a title="<%=SQLArr(1,m)%>" href="detail.asp?id=<%=SQLArr(0,m)%>" target="_blank">
  <img height="140" alt="<%=SQLArr(1,m)%>" src="http://www.shouji138.com<%=SQLArr(2,m)%>" width="107" border="0"></a>
</li>
<li class="green bold">
<a title="<%=SQLArr(1,m)%>" href="detail.asp?id=<%=SQLArr(0,m)%>" target="_blank">
<%=walkgottopic(Trim(SQLArr(1,m)),18)%></a>
</li>
 <li><%=DateValue(SQLArr(3,m))%></li>
 </ul>
	<%
	next
End Function 

%>

ļҵ߼룬ݲͬҵ߼ʵxmlݵĶȡд룬ṩӿڷwebֲá

ĵô룺
list.asp
ֻʾش롣
<%

Dim classid
classid = Request("classid")
If classid = "" Or (Not IsNumeric(classid)) Then Response.write "":Response.End()
classid = CLng(classid)

Dim sPagesize,TotalPage,CurPage,TotalRec,CachePageNum
sPagesize = 20
CachePageNum = 10
CurPage = Trim(Request("page"))
IF CurPage="" Or (Not IsNumeric(CurPage)) Then
  CurPage=1
Else
  CurPage=Clng(CurPage)
End IF
Dim myarr

myarr = GetListarr(classid,CurPage,sPagesize,CachePageNum,TotalRec)

'ҳ
TotalPage = int(clng(TotalRec)/sPagesize*-1)*-1

If Clng(TotalRec)>0 Then	
	showData myarr
End If 
................
%>
ҳײһaspscriptxml档
<script type="text/javascript" src="setcache.asp?action=list&curpage=<%=curpage%>&classid=<%=classid%>"></script>


setcache.asp
ش
<%
openconn
Dim action 
action = Trim(Request("action"))&""

Dim curpage
curpage = Request("curpage")

Dim classid
Dim keyword
Dim thmid
If action = "list" Then
	classid = Request("classid")
	If classid="" Or (Not IsNumeric(classid)) Or curpage="" Or (Not IsNumeric(curpage)) Then
	Else
		CreateListxml CLng(classid),CLng(curpage),20,10,60 * 60 * 2  'xml
	End If 
ElseIf action = "search" Then
	keyword = Trim(Request("keyword"))
	If keyword=""  Then
	Else
		CreateSearchxml keyword,CLng(curpage),20,10,60 * 60 * 2  'xml
	End If 
ElseIf action = "detail" Then
	thmid = Request("id")
	If thmid="" Or (Not IsNumeric(thmid))  Then
	Else
		CreateDetailxml CLng(thmid),60 * 60 * 2  'xml
	End If 
End If 
Call Closeconn
Response.write " "
Response.End 

%>
ˣĴ붼ˣʵ֤ͨķʽҵ138ֻķCPUռʺڴռ½ٶҲߣǰҪ10룬ֻҪ10롣
Ϊ˷еĴ룬صһdemoͬѧϰַhttp://www.shouji138.com/aspnet2/demo
̵ذhttp://www.shouji138.com/aspnet2/demo/xmlcachedemo.rar
QQ:441003232 ӭҽͬ
ҲԷʱ˵Сվֻ:http://www.shouji138.com

