I have got the following soap message and would like to know how to write xpath query to extract the GetNewGUIDResult?
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="06996737-224f-4004-9dad-042222b161fc" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">b89cdee8-18b4-4ea0-a5a1-7b10ace1b23e</ActivityId>
</s:Header>
<s:Body>
<GetNewGUIDResponse xmlns="http://bank.co.com/Service/2011_01/Service">
<GetNewGUIDResult>125959</GetNewGUIDResult>
</GetNewGUIDResponse>
</s:Body>
</s:Envelope>
I tried some some xpath commands but they are giving exceptions. Also I am not sure about the usage of xmlnamespacemanager.
Thanks
Varun
Your XPath expression should work like:
/soap:Envelope/soap:Body/srv:GetNewGUIDResponse/srv:GetNewGUIDResult/text()You would need to declare the namespace prefixes. I don’t know what API your are using, but you need to declare the following namespace prefixes to make the above expression work for you:
soap -> http://schemas.xmlsoap.org/soap/envelope/
srv -> http://bank.co.com/Service/2011_01/Service
If you don’t want to declare namespaces and are using an XPath 2.0 processor you could also do the following (however not recommended!)
/s:Envelope/s:Body/*[namespace-uri()='http://bank.co.com/Service/2011_01/Service' and local-name()='GetNewGUIDResponse']/*[namespace-uri()='http://bank.co.com/Service/2011_01/Service' and local-name()='GetNewGUIDResult']