正在从 httprequest 输出加载 XML 文件

Loading XML file from httprequest output

我正在尝试分析格式为 XML 的 httprequest 的输出。我使用 MSXML2.DOMDocument 将响应加载为 XML 但我收到此错误:

The system cannot find the path specified.

这是 httprequest 的输出,当我收到它时 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>

这是我的 Vbscript 代码,用于将结果加载为 XML 文件:

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

您正在使用 load 方法,

Loads an XML document from the specified location.

但是你想将 XML 作为字符串加载到对象中,所以使用 loadXML,其中

Loads an XML document using the supplied string.