如何使用SOAP Response绑定HTML表

问题描述 投票:1回答:1

我在C#中使用SOAP获取数据。这是我得到的SOAP响应。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetApplicantInfoResponse xmlns="http://tempuri.org/">
<GetApplicantInfoResult xmlns:a="http://*****.*****.org/****/*******.Data" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:DateOfBirth></a:DateOfBirth>
<a:Email></a:Email>
<a:FirstName></a:FirstName>
</GetApplicantInfoResult></GetApplicantInfoResponse>
</s:Body></s:Envelope>

然后使用JavaScript上的.html调用检索

现在需要将数据绑定到HTML Table

javascript soap html-table dynamics-crm-2011
1个回答
1
投票

使用XML Parser然后JavaScript将数据添加到表中。

function getSoap() {
  return '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' +
    '<s:Body>' +
    '<GetApplicantInfoResponse xmlns="http://tempuri.org/">' +
    '<GetApplicantInfoResult xmlns:a="http://*****.*****.org/****/*******.Data" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">' +
    '<a:DateOfBirth></a:DateOfBirth>' +
    '<a:Email>[email protected]</a:Email>' +
    '<a:FirstName>James</a:FirstName>' +
    '</GetApplicantInfoResult></GetApplicantInfoResponse>' +
    '</s:Body></s:Envelope>';
}

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(getSoap(), "text/xml");

document.getElementById("firstname").innerHTML = xmlDoc.getElementsByTagName("a:FirstName")[0].childNodes[0].nodeValue;

document.getElementById("email").innerHTML = xmlDoc.getElementsByTagName("a:FirstName")[0].childNodes[0].nodeValue;
 <table>
  <tr>
    <th>Firstname</th>
    <th>Email</th>
  </tr>
  <tr>
    <td id="firstname"></td>
    <td id="email"></td>
  </tr>
</table> 
© www.soinside.com 2019 - 2024. All rights reserved.