Reputation: 37
i have the xml response below and i need to get the Key value, without success. Tried many variations but it returns no value
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AuthenticateResponse xmlns="http://domain.something/JobServicesV2.asmx">
<AuthenticateResult>
<Result>0</Result>
<Key>fxcCiBSs2fsdfsDF$=</Key>
</AuthenticateResult>
</AuthenticateResponse>
</soap:Body>
</soap:Envelope>
My Javascript code is this:
function Auth() {
var vAnswer ={};
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
var vDomain = "http://domain.something/JobServicesV2.asmx/"
var vAuth = "Authenticate?sUsrName=xxxxx&sUsrPwd=zzzzzzz"
var vURL = vDomain.concat(vAuth);
var data = {};
var xhr = Getxhr();
xhr.open("GET", vURL, false);
xhr.send(data);
var resp = xhr.responseText;
try {
xmlDoc.async = false;
xmlDoc.loadXML(resp);
var vData = xmlDoc.getElementsByTagName("Key")[0].childNodes;
return vData;
}
catch(e) {
X.WARNING("Error Message: " + e.message);
}
vData is always empty
Any idea?
Thanks in advance
Eddiee
Upvotes: 0
Views: 148
Reputation:
This is available in only IE. If you use Chrome or Firefox, you can use DOMParser.
var parser = new DOMParser();
doc = parser.parseFromString(resp, 'text/xml');
var vData = doc.getElementsByTagName("Key")[0].childNodes;
Upvotes: 2