NND,真烦死了,这些特殊字符怎么老出问题啊!!!!

dreamsun 2004-11-25 03:06:57
news.xml内容如下:

<?xml version="1.0" encoding="GB2312"?>
<news>
<one>
<t><font color=red>新浪</font></t>
</one>
</news>

asp的程序:

set doc=server.createobject("MSXML2.DOMDocument")
doc.async=False
doc.load (server.mappath("news.xml"))
set Title=doc.documentElement.selectNodes("//one/t")
Title(0).text=Title(0).text&"测试"

..........保存news.xml的代码省


为什么保存后,我的news.xml变成:

<?xml version="1.0" encoding="GB2312"?>
<news>
<one>
<t>&lt;font color=red&gt;新浪&lt;/font&gt;测试</t>
</one>
</news>


为什么&会自动保存成& ????????????????????????????????
救命啊!!!!我已经弄了一天的时间了~!!!!!!!!!!!!!!!!!!!!!!!!!
...全文
199 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjs_lh 2004-11-29
  • 打赏
  • 举报
回复
建议使用命名空间进行区分。
如:

<?xml version="1.0" encoding="GB2312"?>
<news xmlns:html="http://www.w3c.org/html/40">
<one>
<t>
<html:font color="red">新浪</html:font></t>
</one>
</news>
ssm1226 2004-11-25
  • 打赏
  • 举报
回复
<%
dim xmldoc
set xmldoc=server.CreateObject("MSXML2.DOMDocument")
xmldoc.async=false
xmldoc.load Server.MapPath("test.xml")
set Title=xmldoc.documentElement.selectNodes("//one/t")
Title(0).text=Title(0).text&"测试"
'Response.Write xmldoc.xml
dim fso
set fso=server.CreateObject("Scripting.FileSystemObject")
set f=fso.CreateTextFile("c:\ssm1226.xml",true)
f.write "<?xml version='1.0' encoding='gb2312'?>" + xmldoc.documentElement.xml
%>
dreamsun 2004-11-25
  • 打赏
  • 举报
回复
我是采用字符串连起来,然后再用FSO写入xml文件的,并没有用到xml自身的那个save方法
ssm1226 2004-11-25
  • 打赏
  • 举报
回复
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim CDATASection As IXMLDOMCDATASection
xmlDoc.async = False
xmlDoc.resolveExternals = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set root = xmlDoc.documentElement
Set CDATASection = xmlDoc.createCDATASection("Hello World!")
root.appendChild CDATASection
MsgBox (root.xml)
End If
dreamsun 2004-11-25
  • 打赏
  • 举报
回复
我是用IIS6 windows2003
采用asp脚本

我用<![CDATA[ ...]]>的时候,它竟然把<和>都保存成<和>
最终成<![CDATA[ ...]]>
ssm1226 2004-11-25
  • 打赏
  • 举报
回复
建议你使用:<![CDATA[ ...]]>
ssm1226 2004-11-25
  • 打赏
  • 举报
回复
DOM会自动将内置实体进行转换~
qd_jyx 2004-11-25
  • 打赏
  • 举报
回复
我是说什么语言的操作系统下?
qd_jyx 2004-11-25
  • 打赏
  • 举报
回复
你在什么操作系统下写的代码?

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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