如何使用 SOAP 响应绑定 HTML table

How to bind HTML table using SOAP Response

我正在使用 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.

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

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>james@email.com</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>