我需要检查xml是否有"OperationResponse"如果是,我需要使用XQuery执行一些操作。我尝试了几样东西,但都不成功。下面是我尝试过的一个例子。
示例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>
示例代码
let $response = xmlMessage.xml
if ( $response[Response[contains(text(),'OperationaResponse')]] = 'true')
then
"SomeActions"
预期输出布尔值
您可以尝试以下操作:
/s:Envelope/s:Body/ns0:*[local-name()="OperationResponse"]
为什么不在XQuery中构建测试呢:
if (.//ns0:OperationResponse)
then (: do your query :)
else () (: return nothing :)