欢迎光临
我们一直在努力

ADO Recordset 持久化 格式 XML 读取 保存-ASP教程,数据库相关

建站超值云服务器,限时71元/月

<!– metadata type="typelib" uuid="00000200-0000-0010-8000-00aa006d2ea4" –>

<%

class dataset

private recordset

public tablename, fieldcount

public xmlstring

private tablemap

private sub class_initialize 设置 initialize 事件。

set recordset = server.createobject("adodb.recordset")

recordset.activeconnection = "provider=msdaosp; data source=msxml2.dsocontrol;"

end sub

private sub class_terminate 设置 terminate 事件。

set recordset = nothing

end sub

function readxml(name, filespec)

tablename = name

recordset.open(filespec)

end function

function getxml()

call gettablemap()

do while not recordset.eof

xmlstring = xmlstring + getxmlrow(recordset.fields)

recordset.movenext()

loop

recordset.close

xmlstring = xmlrow(tablename, xmlstring)

getxml = xmlstring

end function

sub gettablemap()

if (not recordset.eof) then

fieldcount = recordset.fields.count – 2

execute("redim tablemap("& fieldcount &")")

for i = 0 to fieldcount

tablemap(i) = recordset.fields.item(i).name

next

end if

end sub

function getxmlrow(item)

dim xmlrowstring

for i = 0 to fieldcount

xmlrowstring = xmlrowstring + xmlfield(tablemap(i), item(i).value)

next

getxmlrow = xmlrow("row", xmlrowstring)

end function

function xmlencode(xmlstring)

xmlstring = replace(xmlstring, "<", "&lt;")

xmlstring = replace(xmlstring, ">", "&gt;")

xmlencode = xmlstring

end function

function xmlfield(nodename, nodevalue)

xmlfield = "<"+ nodename +">"+ xmlencode(nodevalue) +"</"+ nodename +">"

end function

function xmlrow(nodename, nodevalue)

xmlrow = "<"+ nodename +">"+ nodevalue +"</"+ nodename +">"

end function

end class

dim ds : set ds = new dataset

call ds.readxml( "news", server.mappath("news.xml") )

response.contenttype = "text/xml"

response.write(ds.getxml())

set ds = nothing

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ADO Recordset 持久化 格式 XML 读取 保存-ASP教程,数据库相关
分享到: 更多 (0)

相关推荐

  • 暂无文章