在用Microsoft.XMLDOM存储xml文件时,怎么实现里面的换行?

xiaxin 2004-09-01 06:08:19
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>
...全文
151 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
whnnet 2004-09-01
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=EBFC2C8A-3EC5-4DE3-8B45-1CA2DBD4D61A

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧