📄 writexml.asp
字号:
<%
'<?xml version="1.0" encoding="gb2312"?>
'<chatdata>
' <word from="888" to="" time="2003-07-05 20:05:30">大家好!</word>
' <people userID="888">张三</people>
' <people userID="666">李四</people>
'</chatdata>
'http://localhost:8080/chat/htc/xml/writeXML.asp?fromID=888&toID=666&word=大家好&room=room1
fromID = request("fromID")
toID = request("toID")
word = request("word")
room=request("room")
nowtime= FormatDateTime(date(),2) & " " & time()
xmlFileName=server.MapPath(room + ".xml")
response.ContentType = "text/xml"
Response.Charset = "GB2312"
set objDom=server.CreateObject("Microsoft.XMLDOM")
objDom.async = false
objDom.resolveExternals = false
if objDom.load( xmlFileName ) then
'如果这个文件存在,那么插入节点
insertWord
else
'如果文件不存在,那么创建一个
end if
function makeXMLNull()
'创建一个符合格式的xml
makeXMLNull= "<?xml version='1.0' encoding='gb2312'?>" & vbcrlf
makeXMLNull = makeXMLNull & "<chatdata>" & vbcrlf
makeXMLNull = makeXMLNull & " <word from='" & fromID & "' to='a" & toID
makeXMLNull = makeXMLNull & "' time='" & nowtime & "'>" & word
makeXMLNull = makeXMLNull & "</word>"
makeXMLNull = makeXMLNull & "</chatdata>"
end function
sub insertWord()
set root=objDom.documentElement
set newNode = objDom.createNode(1, "word", "")
root.insertBefore newNode, root.childNodes.item(0)
newNode.setAttribute "from", fromID
newNode.setAttribute "to", toID
newNode.setAttribute "time", nowtime
newNode.text=word
objDom.save xmlFileName
set newNode=nothing
set root=nothing
set objDom=nothing
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -