Use asp to generate xml files. At first I used fso, which only used writing. At the same time, I also gave you the method of reading files.
ASP query XML by keyword problem
'------------------------------------------------ -----
'Read the fileReadTxtFile(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
setts=nothing
set fso=nothing
End Function
'------------------------------------------------ ----------
'Write information to file
'------------------------------------------------ ----------
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
'------------------------------------------------ ----------
'Generate xml file
'------------------------------------------------ ----------
msg = <?xml version=1.0 encoding=utf-8?>
msg=msg & <bcaster>
msg=msg & <item item_url=http://www.vevb.com itemtitle=Script Home/>
msg=msg & </bcaster>
call WriteTxtFile(msg,x1.xml)
fso is ascii encoded by default, because utf-8 encoding must be used, use ado.stream to write this file, the code is as follows:
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.vevb.com itemtitle=Script Home/>
msg=msg & </bcaster>
call CreateFile(msg,x1.xml)