从httprequest输出加载XML文件 [英] Loading XML file from httprequest output

查看:93
本文介绍了从httprequest输出加载XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这是我以 ResponseText 收到的httprequest的输出:

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>

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

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

推荐答案

您正在使用

You are using the load method, which

从指定位置加载XML文档.

Loads an XML document from the specified location.

但是,您要将XML作为字符串加载到对象中,因此请使用

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

使用提供的字符串加载XML文档.

Loads an XML document using the supplied string.

这篇关于从httprequest输出加载XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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