I'm unable to extract from the below response message:-
<?xml version="1.0" encoding="UTF-8"?> <SendMessageResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> <SendMessageResult> <MessageId>90edbebd-880f-4334-95fb-9faf8723b963</MessageId> <MD5OfMessageBody>d76ca0bbee493c268b5f17052f7ca3e4</MD5OfMessageBody> </SendMessageResult> <ResponseMetadata> <RequestId>6157f8d7-0173-5179-b8a9-ae00f894193c</RequestId> </ResponseMetadata> </SendMessageResponse>
Below is my extract message policy-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <DisplayName>Extract Variables-1</DisplayName> <Properties/> <Source clearPayload="true">response</Source> <XMLPayload stopPayloadProcessing="false"> <Namespaces> <Namespace prefix="awssqs">http://queue.amazonaws.com/doc/2012-11-05/</Namespace> </Namespaces> <Variable name="requestId" type="string"> <XPath>/awssqs:SendMessageResponse/ResponseMetadata/RequestId</XPath> </Variable> </XMLPayload> </ExtractVariables>
What am I doing wrong? If the namespace is removed this policy is extracting perfectly. What should be the correct xpath for this message.
Note:- The xmlns tag is coming after SendMessageResponse
Sorry about that. Using XPath with XML Namespaces is sort of tricky and you need to get everything just right. You were sooooo close.
here's what I suggest
<ExtractVariables name="Extract-Variables-1"> <Source>response</Source> <XMLPayload> <Namespaces> <Namespace prefix="q">http://queue.amazonaws.com/doc/2012-11-05/</Namespace> </Namespaces> <Variable name="requestId" type="string"> <XPath>/q:SendMessageResponse/q:ResponseMetadata/q:RequestId/text()</XPath> </Variable> </XMLPayload> </ExtractVariables>
Explanation: