欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp下用fso和ado.stream寫xml文件的方法

 更新時(shí)間:2008年10月15日 11:24:37   作者:  
用asp來生成xml文件,一開始我用fso,只用了寫,同時(shí)把讀文件的辦法也給大家

asp按關(guān)鍵字查詢XML的問題
'------------------------------------------------------
'讀取文件 ReadTxtFile(FileName)
'------------------------------------------------------
Function ReadTxtFile(FileName)
Dim fso,f1,ts,FilePath
FilePath=server.mappath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(FilePath,1,1)
ReadTxtFile = ts.ReadAll
set ts=nothing
set fso=nothing
End Function
'------------------------------------------------------------
'把信息寫入文件
'------------------------------------------------------------
Function WriteTxtFile(Text,FileName)
path=Server.MapPath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(path,true)
f1.Write (Text)
f1.Close
End Function
'-----------------------------------------------------------
'生成xml文件
'-----------------------------------------------------------
msg = "<?xml version=""1.0"" encoding=""utf-8""?>"
msg=msg & "<bcaster>"
msg=msg & "<item item_url=""http://www.dbjr.com.cn"" itemtitle=""腳本之家""/>"
msg=msg & "</bcaster>"
call WriteTxtFile(msg,"x1.xml")


fso默認(rèn)是ascII編碼的,因?yàn)楸仨毷褂胾tf-8編碼,用ado.stream來寫這個(gè)文件,代碼如下:
Sub CreateFile(Text,FileName)
Dim st
Set st=Server.CreateObject("ADODB.Stream")
st.Type=2
st.Mode=3
st.Charset="utf-8"
st.Open()
st.WriteText Text
st.SaveToFile Server.MapPath(FileName),2
st.Close()
Set st=Nothing
End Sub
msg = "<?xml version=""1.0"" encoding=""utf-8""?>"
msg=msg & "<bcaster>"
msg=msg & "<item item_url=""http://www.dbjr.com.cn"" itemtitle=""腳本之家""/>"
msg=msg & "</bcaster>"
call CreateFile(msg,"x1.xml")

相關(guān)文章

最新評(píng)論