Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900