Nor able to retrieve xml response value inside tag

Hi,

I am trying to fetch the value of fifth tag(Happy) inside below sample xml but not able to do so.

 

This is what I have tried so far

var xmlObj = request.content.asXML;

var S = new Namespace('http://schemas.xmlsoap.org/soap/envelope/');

var l= new Namespace ('test');

var v1 = xmlObj.S::Body.l::first.I::second.toString();

var v2 = xmlObj.S::Body.l::first.I::second.I::third.toString();

I am able to get v1 but not v2. How can I ge5 the value of v2.

Can some one please help on this.

 

<soap:Envelope

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<first xmlns="test">

<second>

&lt;third&gt;&lt;fourth&gt;&lt;fifth&gt;Happy&lt;/fifth&gt;&lt;/fourth&gt;&lt;/third&gt;

</second>

</first>

</soap:Body>

</soap:Envelope>

 

 

 

0 3 92
3 REPLIES 3

third, fourth, fifth are not part of your xml schema, they're characters in the value of <second>

https://www.w3.org/TR/xml11/#sec-predefined-ent

Thank you for inputs!

Is there any way we can retrieve the values using JS?

Maybe you could look at reencoding the characters in javascript or with the message template replace-all function https://docs.apigee.com/api-platform/reference/message-template-intro#replace-all-function