Xml 使用VBScript解析SOAP响应

Xml 使用VBScript解析SOAP响应,xml,web-services,asp-classic,vbscript,Xml,Web Services,Asp Classic,Vbscript,我对XML和web服务非常陌生,所以我正在寻找一些方向。我有一个经典的ASP web应用程序(好吧,别开玩笑了!),它使用web服务从数据库检索数据。我能够调用web服务并接收SOAP响应。我的问题出现在尝试解析响应时。我调用web服务的代码如下所示 Dim objXMLHttp, strEnvelop, strReturn strEnvelope = <I build the soap message here> set objXMLHttp = Server.CreateObje

我对XML和web服务非常陌生,所以我正在寻找一些方向。我有一个经典的ASP web应用程序(好吧,别开玩笑了!),它使用web服务从数据库检索数据。我能够调用web服务并接收SOAP响应。我的问题出现在尝试解析响应时。我调用web服务的代码如下所示

Dim objXMLHttp, strEnvelop, strReturn
strEnvelope = <I build the soap message here>
set objXMLHttp = Server.CreateObject("MSXML2.XMLHTTP")
objXMLHttp.open "POST", "web service URL", false
objXMLHttp.setRequestHeader "Content-Type", "text/xml"
objXMLHttp.send strEnvelope
strReturn = objXMLHttp.responseText
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<lookupCaseOutputCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/lookupCase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<lookupCaseOutput>
<C_CASE_ID>100000</C_CASE_ID>
<I_FIRST_NM>BERNADINE</I_FIRST_NM>
<I_MI_NM>C</I_MI_NM>
<I_LAST_NM>TWOTEETH</I_LAST_NM>
<I_DOB_DT>1977-06-26</I_DOB_DT>
</lookupCaseOutput>
</lookupCaseOutputCollection>
</Body>
</Envelope>
这就是我被卡住的地方。我需要能够提取和显示单个标记C_CASE_ID、I_FIRST_NM等的值。我不知道如何做到这一点。有人有什么建议/例子吗

谢谢。

首先,您不需要从字符串加载XML数据。后者用于从文件加载XML数据

将结构解析为
DOMDocument
对象后,可以使用属性和方法。我建议使用带有表达式的
selectNodes()
selectSingleNode()
来选择您感兴趣的节点:

xmlDoc.loadXML strReturn

WScript.Echo xmlDoc.selectSingleNode("//C_CASE_ID").text
WScript.Echo xmlDoc.selectSingleNode("//I_FIRST_NM").text
'...

当然,当我发布这个问题时,我在“相关”主题下仔细查看,发现一个主题完美地回答了我的问题。当然,在我发布之前的任何搜索中都没有显示。数字:-)
xmlDoc.loadXML strReturn

WScript.Echo xmlDoc.selectSingleNode("//C_CASE_ID").text
WScript.Echo xmlDoc.selectSingleNode("//I_FIRST_NM").text
'...