asp使用xml存储数据

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']")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值