响应XML返回带有垃圾字符 [英] Response XML returns with junk characters

查看:73
本文介绍了响应XML返回带有垃圾字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在维护一个经典的ASP网站,当用户登录该网站时,vbs脚本通过XMLHttp对象从服务器获取XML文件,然后解析XML并进行进一步处理.我的问题是,响应XML附加了一些垃圾字符 F vVO \3ӱ,由于该XML无法解析,因此应用程序暂停了.并非每次都发生这种情况,我们还没有在我们的开发环境中重现这种情况.但是,一些用户遇到此问题经常退出.
以下是用于获取XML的函数

We are maintaining a classic asp web site, when a users logs into the site a vbs scripts gets a XML file from the server through XMLHttp object and then parses the XML and does the some further processing. My problem is that the Response XML gets appended with some sort of junk characters F vVO \3ӱ and due this the XML is not parsed and the application halts. This does not happen every time and we are yet to reproduce this at our development environment. However some users are experiencing this issue quit often.
Following is the function used to get the XML

Function fsendHTTPGet(lFName, lObjXML)
	   Dim oMsg, retVal
		
	   set lObjXML = CreateObject("MSXML.DomDocument")
	   set oMsg = CreateObject("Microsoft.XMLHTTP")

	   call oMsg.open("GET", lFName, false)
	   call oMsg.setRequestHeader("Content-Type", "text/xml-SOAP")
	   call oMsg.setRequestHeader("Internal", "true")
	   call oMsg.send()
	   lObjXML.async=false	
	   ''lObjXML.load(lFName)	
	   lObjXML.loadXML(oMsg.responseText)

	   if fParsed(lObjXML)<> true then ''checks if the object contents valid XML
		   set retVal = window.open() 
		   retVal.document.write(oMsg.responseText) ''here i can see the repsone XML with junk characters appended at the end. One of the users had send us the screen of this.

			fsendHTTPGet = "false"
			msgBox fDirectGetValue(gClientSideLiteralXMLObj,"ServerError")	''"Invalid server response : Parse Error"
	   else
			''if error then always show message
			if fDirectGetValue(lObjXML, "XML/Error/@ErrorNo") = "TimeOut" then
				if sMessage <> "" then
					msgBox sMessage
				end if	
				call fDoRedirect(fDirectGetValue(lObjXML, "XML/Redirect"),"")
				fsendHTTPGet = "false"
				exit function
			end if

			fsendHTTPGet = "true"
	   end if

	End Function

推荐答案

我使用C ++语言编写代码,因此我无法提供示例,但我相信我可以解释.

如果这发生在第1行的位置1之前,则为二进制顺序标记",并且如果您的代码正在读取第三方XML,则需要对您的代码进行调整以接受BOM.

另一方面,如果XML是内部"生成的,则可以指示有问题的模块在创建它时禁止显示BOM.
I code in C++ so I cant provide a sample but I believe I can explain.

If this is occurring before position 1 on line 1, then its the Binary Order Mark, and if your code is reading third party XML your code needs to be adapted to accept the BOM.

On the other hand if the XML is being produced ''inhouse'' then the offending module can be instructed to suppress the BOM when creating it.


这篇关于响应XML返回带有垃圾字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆