Loading XML file from httprequest output

瘦欲@ 提交于 2019-12-20 07:27:56

问题


I am trying to analyse the output of httprequest which is formatted as XML. I use MSXML2.DOMDocument to load the response as XML but I receive this error:

The system cannot find the path specified.

this is the output of httprequest when I receive it as ResponseText:

<?xml version="1.0" encoding="utf-8"?>
<resultObj>
  <result>False</result>
  <invoiceNumber>1</invoiceNumber>
  <referenceNumber>21669145</referenceNumber>
  <transactionDate>2016/05/18 20:10:07</transactionDate>
</resultObj>

and this is my Vbscript code to load the result as XML file:

data= "invoiceUID=1"
Set httpRequest = Server.CreateObject("MSXML2.XMLHTTP.6.0")
httpRequest.Open "POST", "https://some url", False
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send data

postResponse = httpRequest.ResponseXML.xml

Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument")
xmlDOM.async = False
xmlDOM.setProperty "ServerHTTPRequest", True
xmlDOM.Load(postResponse) ///// I think this line fails

If xmlDOM.ParseError <> 0 Then
  response.write xmlDOM.ParseError.Reason
Else
  response.write "file loaded"
End If

回答1:


You are using the load method, which

Loads an XML document from the specified location.

However you want to load the XML as a string into the object, so use loadXML, which

Loads an XML document using the supplied string.



来源:https://stackoverflow.com/questions/37339797/loading-xml-file-from-httprequest-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!