ASP如何读取客户端提交上来的XML字符串

边城的刀声 2006-11-17 06:08:13
字符串经格式化后形式如下:
<record type="1">
<id>0</id>
<title>清华ddddddddddd</title>
<url>http://www.a.cn/school_show.asp?id=3001</url>
<fee>0</fee>
<prePrice>0</prePrice>
</record>
急!
...全文
269 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuStanly 2006-11-17
  • 打赏
  • 举报
回复
TMD打错了
<%Response.ContentType = "text/xml"%>
<%Response.charset = "gb2312"%>
<%
dim xmlStr
xmlStr = "<record type=""1""><id>0</id><title>清华ddddddddddd</title><url>http://www.a.cn/school_show.asp?id=3001</url><fee>0</fee><prePrice>0</prePrice></record>"
xmlStr = "<?xml version=""1.0"" encoding=""gb2312""?><root>"&xmlStr&"</root>"

set xml = server.createobject("Microsoft.XMLDOM")
xml.loadXML(xmlStr)
xml.async = false
set title = xml.selectsinglenode("//root/record/title")
response.write title.text
response.end
set xml = nothing
%>
xuStanly 2006-11-17
  • 打赏
  • 举报
回复
dim xmlStr
xmlStr = "<record type=""1""><id>0</id><title>清华
<%Response.ContentType = "text/xml"%>
<%Response.charset = "gb2312"%>
<%
ddddddddddd</title><url>http://www.a.cn/school_show.asp?id=3001</url><fee>0</fee><prePrice>0</prePrice></record>"
xmlStr = "<?xml version=""1.0"" encoding=""gb2312""?><root>"&xmlStr&"</root>"

set xml = server.createobject("Microsoft.XMLDOM")
xml.loadXML(xmlStr)
xml.async = false
set title = xml.selectsinglenode("//root/record/title")
response.write title.text
set xml = nothing
response.end
%>
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
不行,设置了contenttype为text/xml也是不行呀
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
xmlStr = "<?xml version=""1.0"" encoding=""gb2312""?><root>"&xmlStr&"</root>"
set xRows = xmlStr.getElementsByTagName("record")
提示错误:缺少对象: '<record type="1"><id'
xuStanly 2006-11-17
  • 打赏
  • 举报
回复
那可能是字符串contenttype的问题了。
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
是的,这个我也加了,可就是不行
xuStanly 2006-11-17
  • 打赏
  • 举报
回复
直接加载字符串也是没有问题的啊。
但是字符串的第一行必须是
<?xml version="1.0" encoding="GB2312"?>
前面不能有空格和空行。
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
难道非得用保存成临时文件,然后再加载吗
还有其它的办法吗
高…………………………手
HELP!
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
UP
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
如果是加载xml文档的话,是没有问题的
就是访问xml形式的字符串时,却会出错
xuStanly 2006-11-17
  • 打赏
  • 举报
回复
response.write xml.readystate
看看状态怎么样。
边城的刀声 2006-11-17
  • 打赏
  • 举报
回复
xmlStr = request("xmlStr")
set xRows = xmlStr.getElementsByTagName("record")
直接这样写就出错了

28,390

社区成员

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

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