0

I need to extract this value from this XML response using jQuery

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:loginResponse>
<loginReturn xsi:type="xsd:string">1cfc56c2007dec7b32cf20f0d44c2eeb</loginReturn>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1
  • Can you share the code you have tried so far? Commented Jul 6, 2015 at 16:43

1 Answer 1

1

If you want to extract the loginReturn, then here is a possible way:

var xmlData = '<?xml version="1.0" encoding="UTF-8"?>'+
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento"'+ 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'+ 
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'+
'<SOAP-ENV:Body>'+
'<ns1:loginResponse>'+
'<loginReturn xsi:type="xsd:string">1cfc56c2007dec7b32cf20f0d44c2eeb</loginReturn>'+
'</ns1:loginResponse>'+
'</SOAP-ENV:Body>'+
'</SOAP-ENV:Envelope>';


var parsedData = $.parseXML(xmlData);
$('#resultlbl').text($(parsedData).find( "loginReturn").text())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<label id='resultlbl'/>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.