亲爱的大家,我有以下结构的 SOAP react
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://lbs.xius.com/messages/lbs" xmlns:ns2="http://lbs.xius.com/messages/common" xmlns:ns3="http://billing.xius.com/BalanceManagement.wsdl" xmlns:ns4="http://billing.xius.com/BalanceManagement.xsd" xmlns:ns5="http://billing.xius.com/common/header/HeaderDetails.xsd" xmlns:ns6="http://billing.xius.com/common/error/ErrorDetails.xsd" xmlns:ns8="http://lbs.xius.com/services/lbs" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<ns1:SLIAnswer>
<ns1:Ver />
<ns1:ResponseData>
<ns1:ResultAndAddInfo>
<ns1:Result>
<ns1:Result>SYSTEM_FAILURE</ns1:Result>
<ns1:ResultId>1</ns1:ResultId>
</ns1:Result>
</ns1:ResultAndAddInfo>
</ns1:ResponseData>
</ns1:SLIAnswer>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
从这个字符串中,我想获取“ResponseData”节点中的所有子节点及其值 我如何使用 javascript 做到这一点
最佳答案
您可以将 DOMParser()
与命名空间 DOM 函数一起使用。
var parser = new DOMParser();
var doc = parser.parseFromString(xml, "application/xml");
var responseData = doc.getElementsByTagNameNS('http://lbs.xius.com/messages/lbs', 'ResponseData');
关于javascript - 如何在javascript中处理xml字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27087077/