【发布时间】:2018-08-26 21:44:29
【问题描述】:
目前我正在使用 SOAP 来检索我的值。所以现在的问题是
当我收到响应时,它是 XML 格式的,所以为了查看响应,我做了一个 response.responseText
所以代码看起来像这样:
$.ajax(settings).complete(function (response) {
console.log(response.responseText);
}
我在 console.log 中得到的响应是:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns:findResponse xmlns:ns="http://property.property.ws" xmlns:ax221="http://property.property.ws/xsd" xmlns:ax223="http://filter.common.nyx.nl/xsd">
<ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">48</ns:return>
<ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">50</ns:return>
<ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">51</ns:return>
</ns:findResponse>
</soapenv:Body>
</soapenv:Envelope>
如果你向右滚动,你可以看到我的三个值 48 50 和 51。
所以我想提取这 3 个值。截至目前,我正在这样做:
var xmlDoc = $.parseXML(response.responseText);
var $xml = $(xmlDoc);
var primaryKeysOfProperties = $xml.text();
console.log(primaryKeysOfProperties);
我从 primaryKeysOfProperties 得到的结果是 485051。
期望的输出: 我想让输出变成这样的 48,50,51。
我已经在这里工作了 2 天.. 我研究并发现了一些类似的堆栈溢出问题,但这些问题有点不同。我试图改变,但我失败了。任何人都可以帮忙吗? :)
【问题讨论】:
标签: javascript xml soap