DOM parsing is not working in Chrome browser

393 views Asked by At

I'm trying to parse the response from a XMLHttpRequest using XrmServiceToolkit for CRM 2015. The code for parsing the results is working fine in IE 11, however it is not working as expected in Chrome. Please assist.

Here are the details :

var requestMain = ""
    requestMain += "      <request i:type=\"b:RetrieveRecordChangeHistoryRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
    requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
    requestMain += "          <a:KeyValuePairOfstringanyType>";
    requestMain += "            <c:key>Target</c:key>";
    requestMain += "            <c:value i:type=\"a:EntityReference\">";
    requestMain += "              <a:Id>" + entityId + "</a:Id>";
    requestMain += "              <a:LogicalName>" + entityName + "</a:LogicalName>";
    requestMain += "              <a:Name i:nil=\"true\" />";
    requestMain += "            </c:value>";
    requestMain += "          </a:KeyValuePairOfstringanyType>";
    requestMain += "        </a:Parameters>";
    requestMain += "        <a:RequestId i:nil=\"true\" />";
    requestMain += "        <a:RequestName>RetrieveRecordChangeHistory</a:RequestName>";
    requestMain += "      </request>";

var changeHistoryResponse = XrmServiceToolkit.Soap.Execute(requestMain);
var results = changeHistoryResponse.getElementsByTagName("a:Results")[0];

...

var auditRecords = results.childNodes[0].childNodes[1].getElementsByTagName("b:AuditDetail");

The line changeHistoryResponse.getElementsByTagName("a:Results")[0]; is working fine in IE, however it returns null in Chrome. Because of this the other part of the code is throwing error

var auditRecords = results.childNodes[0].childNodes[1].getElementsByTagName("b:AuditDetail");

Cannot read property 'childNodes' of undefined

0

There are 0 answers