www.u8686.com-信息发布平台
asp使用xml存储数据
Function RecordsetToxml(Recordset,row,xmlroot)
Dim i,node,rs,j,DataArray,row1
row1=row
If xmlroot="" Then xmlroot="xml"
If row="" Then row="row"
Set RecordsetToxml=Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
'RecordsetToxml.setProperty "SelectionLanguage","XPath"
RecordsetToxml.appendChild(RecordsetToxml.createElement(xmlroot))
If Not Recordset.EOF Then
DataArray=Recordset.GetRows(-1)
For i=0 To UBound(DataArray,2)
Set Node=RecordsetToxml.createNode(1,row,"")
j=0
For Each rs in Recordset.Fields
node.attributes.setNamedItem(RecordsetToxml.createNode(2,LCase(rs.name),"")).text= DataArray(j,i)& ""
j=j+1
Next
RecordsetToxml.documentElement.appendChild(Node)
Next
End If
DataArray=Empty
End Function
Function Aspxml(Category)
Dim Data,I,Text,C,Sql,Counts
If Not ObjIsEmpty(Category) Then
Set Aspxml = Application(CacheName&"_"&Category&"list")
Exit Function
End If
If Category="ad" Then
Sql="Select * From China_Ad Order By [ID]"
Elseif Category="city" Then
Sql="Select * From China_City Order By [IndexID]"
ElseIf Category="wad" Then
Sql="Select * From China_Wad Order By [IndexID]"
ElseIf Category="link" Then
Sql="Select * From China_Link Order By [IndexID]"
Else
Sql="Select * From China_Type Order By [IndexID]"
End If
Set Rs=Conn.Execute(Sql)
Application.Lock
Set Application(CacheName&"_"&Category&"list")=RecordsetToxml(Rs,Category,Category&"list")
Application(CacheName & "_" & Category &"_-time") = Now
Application.UnLock
Rs.Close:Set Rs = NoTHing
Set Aspxml = Application(CacheName&"_"&Category&"list")
End Function
调用:
Set DataCity=Aspxml("city").documentElement.SelectNodes("city[@id>'0'][@twoid='0']")

720

被折叠的 条评论
为什么被折叠?



