如何用js读取WebService返回的XML结果

2025-03-10 16:43:05
推荐回答(1个)
回答1:

function b() {

var weburl = 'http://10.10.10.160:1000/CRM.asmx';

var context = Xrm.Page.context;

var id = context.getUserId();

var info;

info = '';

info = info + 'http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="'">http://schemas.xmlsoap.org/soap/envelope/">';

info = info + '';

info = info + '
'">http://tempuri.org/">';

info = info +
' ' + id +
'';

info = info + ' ';

info = info + ' ';

info = info + '';

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.Open("GET", weburl, false);

alert(xmlhttp);

xmlhttp.SetRequestHeader("Content-Type", "text/xml;
charset=gb2312");

xmlhttp.Send(info);

var rst =
xmlhttp.responseXML.selectSingleNode('//GetLoginNameResponse//GetLoginNameResult').text;

winddow.document.getElementByIdx_x("new_mark").value=rst;

}