源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2022-08-17 05:05 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:asp下用fso和ado.stream写xml文件的方法
asp按关键字查询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.1sucai.cn"" itemtitle=""编程素材网""/>" msg=msg & "</bcaster>" call WriteTxtFile(msg,"x1.xml") fso默认是ascII编码的,因为必须使用utf-8编码,用ado.stream来写这个文件,代码如下: 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.1sucai.cn"" itemtitle=""编程素材网""/>" msg=msg & "</bcaster>" call CreateFile(msg,"x1.xml")
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部