how to extract particular xml element from payload

How tp extract the value of ID from the below XML. I just want the value “24070812”

172.30.200.164

24070812

</OrderExtendedDataDictionary

1 Like
Use Extract Variable policy. See below code 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="extractXMLPaayload">
    <DisplayName>extractXMLPaayload</DisplayName>
    <Source clearPayload="false">request</Source>
    <VariablePrefix>order</VariablePrefix>
    <XMLPayload stopPayloadProcessing="false">
        <Namespaces/>
        <Variable name="key" type="integar">
            <XPath>//SubmitOrderRequest/Order/OrderExtendedDataDictionary/Value[@Key='ID']/text()</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>

You can check this extracted value by printing in JS policy

var key = context.getVariable('order.key');
print(key);

1 Like

There’s lots of online XPath testers such as https://codebeautify.org/Xpath-Tester