XMLHTTP接收XML文件的一个编码问题
set req=server.createObject( "Microsoft.XMLHTTP ")
dim url:url= "https://www.nta-merchant.com/gateway/transfer/v1/member_to_merchant/index.cfm "
dim param
param= "amount= "&request( "amount ")& "¤cy=RMB "& "&net_account= "&request( "net_account ")& "&secure_id= "&request( "secure_id ")
param = param & "&merch_account= "&request( "merch_account ")& "&merchant_id=53179&merch_transid=10000 "
req.open "post ",url,false
req.setRequestHeader "content-type ", "application/x-www-form-urlencoded "
req.send(param)
dim xmlStream
xmlStream=req.responseXML.xml
response.write "111111111 "&xmlStream& "2222222222222 "
Dim oXmlDom
Set oXmlDom = Server.CreateObject( "Microsoft.XMLDOM ")
oXmlDom.LoadXML(xmlStream)
Dim oNode
Set oNode =oXmlDom.selectSingleNode( "//approval ").text
Response.Write(oNode)
Set req=Nothing
Set oXmlDom=Nothing
上面是我的程序,提交后对方返回的XML格式如下
<?xml version= "1.0 " encoding= "ISO-8859-1 " ?>
<netdirect version= "4.0 ">
<approval> no </approval>
<error> 1002 </error>
<custom_1 />
<custom_2 />
<custom_3 />
</netdirect>
现在我xmlStream=req.responseXML.xml读不到对方的XML,请问是什么原因啊?和encoding= "ISO-8859-1 "有关系吗?运行后还有这个错误
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象: 'selectSingleNode(...) '
------解决方案--------------------为什么一定要load responseXML呢,不是说过对方的content-type是text/html,xmlhttp不会处理这类数据,load responseText就可以,这个调试成功了的
Dim req
set req = server.createObject( "Microsoft.XMLHTTP ")
dim url:url= "https://www.nta-merchant.com/gateway/transfer/v1/member_to_merchant/index.cfm "
req.open "post ",url,false
req.setRequestHeader "content-type ", "application/x-www-form-urlencoded "
req.send
dim xmlStream
xmlStream = req.responseText
Dim oXmlDom
Set oXmlDom = server.CreateObject( "Microsoft.XMLDOM ")
oXmlDOM.async = False
oXmlDom.loadXML xmlStream
Response.Write Server.HTMLEncode(oXmlDOM.xml)
Set req=Nothing
Set oXmlDom=Nothing