非常简单地说,如何检索数据?我想要一个可以循环显示此数据的数组。这就是我一直在尝试的,没有成功:
<cfset apicall = XMLParse(httpResponse.filecontent)>
<cfset certArray = xmlSearch(apiCall,"//BNEHFTPOfficerRosterSvcResponse/BNEHFTPOfficerRosterSvcResult/BNEHFTPOfficerRosterSvcResponse")>
特别是第二行或其任何变体返回空数组。我做错了什么?
感谢。
根据建议修改我的代码:
<cfset cols = xmlSearch(apiCall,"//*[local-name()='BNEHFTPOfficerRosterSvcResponse']")[1].XmlChildren>
如果我转储它,我会得到第二张图片。
现在我正在努力接近拥有我需要的数据数组。我已经尝试添加另一个.XmlChildren但它会引发错误。这令人困惑! :)
答案 0 :(得分:0)
由于上面的XPath seaerch是基于XML对象的根目录(当前为soap:Envelope
),因此您需要在运行XPath查询之前将XML对象递归到soap:Body
< / p>
var soapBody = apiCall[ "soap:Envelope" ][ "soap:Body" ];
然后你可以在上面执行Xpath搜索。
或者,您可以使用更开放的XPath搜索字符串,它将为您执行递归:
xmlSearch(apicall,"//*[local-name()='BNEHFTPOfficerRosterSvcResponse']")