在用Microsoft.XMLDOM存储xml文件时,怎么实现里面的换行?
writexml.asp
------------------------
<%
'http://localhost/writeXML.asp?fromID=昵称&word=聊天数据
fromID = request("fromID") '昵称
word = request("word") '数据
nowtime = FormatDateTime(date(),2) & " " & time() '当前时间
set objDom=server.CreateObject("Microsoft.XMLDOM")
xmlFileName=server.MapPath("room1.xml")
response.ContentType = "text/xml"
Response.Charset = "GB2312"
if objDom.load( xmlFileName ) then '如果这个文件存在,那么插入节点
set root=objDom.documentElement
set newNode = objDom.createNode(1, "content", "")
root.insertBefore newNode, root.childNodes.item(0)
newNode.setAttribute "name", fromID
newNode.setAttribute "time", nowtime
newNode.text=word
objDom.save xmlFileName
set newNode=nothing
set root=nothing
set objDom=nothing
end if
%>
运行后data.xml中的数据没有换行。
data.xml
--------------------------
<?xml version="1.0" encoding="gb2312"?>
<chatdata>
<content name="第五个昵称" time="2004-9-1 17:57:39">第二条聊天数据</content><content name="第四个昵称" time="2004-9-1 17:57:06">第二条聊天数据</content><content name="第三个昵称" time="2004-9-1 17:55:35">第二条聊天数据</content><content name="第二个昵称" time="2004-9-1 17:48:48">第二条聊天数据</content><content name="昵称" time="2004-9-1 17:45:09">聊天数据</content><content name="myname" time="2004-9-1 17:44:21">hh</content></chatdata>
我想在运行 http://localhost/writeXML.asp?fromID=昵称&word=聊天数据 后,插入data.xml中的数据是:
<?xml version="1.0" encoding="gb2312"?>
<chatdata>
<content name="第五个昵称" time="2004-9-1 17:57:39">第二条聊天数据</content>
<content name="第四个昵称" time="2004-9-1 17:57:06">第二条聊天数据</content>
<content name="第三个昵称" time="2004-9-1 17:55:35">第二条聊天数据</content>
<content name="第二个昵称" time="2004-9-1 17:48:48">第二条聊天数据</content>
<content name="第一个昵称" time="2004-9-1 17:48:48">第一条聊天数据</content>
<chatdata>