如果 SOAP 响应具有名称 Space,则无法使用 VBScript select 来自 SOAP 响应的节点值

Unable to select the node value from the SOAP Response using VBScript in case SOAP Response has Name Space

我正在尝试使用 VBScript 在 XML 中获取一些节点值。如果我在下面的脚本中使用正常的 XML,那么它会正确获取预期的节点值。但是,如果我使用具有命名空间的 SOAP 响应,则下面的脚本会在突出显示的行中抛出以下错误:

Object Required: 'nNode'

脚本:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set xmlDoc = CreateObject("Microsoft.XMLDOM")

xmlDoc.Load editName
xmlDoc.SetProperty "SelectionNamespaces", "xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sch='http://www.exchangerate.com/webservices/schemas' xmlns:xbe='http://www.exchangerate.com/rate'"

Set nNode = xmlDoc.SelectSingleNode(tag)

objSheet.Cells(i, Column).value = nNode.text  '<-- this fails

strResult = xmlDoc.Save(editName)   

我该如何解决这个问题?

示例响应 XML:


输入:

tag="/SOAP-ENV:Envelope/SOAP-ENV:Body/sch:Request/sch:Response/xbe:ConversionRateResult"

我们必须使用相对Xpath 来解析SOAP Response,并且通过使用相对Xpath as tag="//xbe:ConversionRateResult" 解决了上述问题。