'Extract value from soap response based on tag value
My soap response is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<e:Envelope xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fn35="http://www.filenet.com/ns/fnce/2005/02/ws/schema" xmlns:fn40m="http://www.filenet.com/ns/fnce/2006/11/ws/MTOM/schema"
xmlns:fn40="http://www.filenet.com/ns/fnce/2006/11/ws/schema" xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:e="http://www.w3.org/2003/05/soap-envelope">
<e:Body>
<ExecuteChangesResponse xmlns="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
<ChangeResponse id="1" classId="Document" objectId="{F4CA442A-CE20-45E8-8372-7F34367113A4}"
objectStore="{2417ADC1-633A-4DE3-ADC1-7B6E85E832A9}"
updateSequenceNumber="0" accessAllowed="998903">
<Property i:type="fn40:SingletonString" propertyId="Owner" settable="1">
<Value>testUser</Value>
</Property>
<Property i:type="fn40:SingletonId" propertyId="Id">
<Value>{F4CA442A-CE20-45E8-8372-7F34367113A4}</Value>
</Property>
</ChangeResponse>
</ExecuteChangesResponse>
</e:Body>
</e:Envelope>
and I want to extract the value of the property that has propertyId="Id" so I tried the following and it returns an empty string
<property expression="//ExecuteChangesResponse/ChangeResponse/property[@propertyId='Id']/text()" name="Id" scope="default"
type="STRING"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
Solution 1:[1]
I was able to extract the value as follows :
<property expression="$body/fn:ExecuteChangesResponse/fn:ChangeResponse/fn:Property[@propertyId='Id']/fn:Value" name="Id" scope="default"
type="STRING"
xmlns:fn="http://www.filenet.com/ns/fnce/2006/11/ws/schema" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mahmoud Saleh |