I need to check if the xml has a "OperationResponse" in it and if yes, i need to perform some actions using XQuery. I tried few things and was not successfull. Below is an example of something that i tried.
Sample XML
<s:Envelope xmlns:s="http://examplens/soap/envelope/">
<s:Body>
<ns0:OperationResponse xmlns:ns0="urn:abcd:efgh:bc:1">
<ns0:DocumentHeader>
<ns0:Timestamp>2022-12-07T09:30:51 01:00</ns0:Timestamp>
<ns0:MessageID>abcd</ns0:MessageID>
</ns0:DocumentHeader>
Sample Code
let $response = xmlMessage.xml
if ( $response[Response[contains(text(),'OperationaResponse')]] = 'true')
then
"SomeActions"
Expected Output A boolean value
CodePudding user response:
Why not build the test into your XQuery:
if (.//ns0:OperationResponse)
then (: do your query :)
else () (: return nothing :)
CodePudding user response:
You can try the following.
/s:Envelope/s:Body/ns0:*[local-name()="OperationResponse"]