Unable to extract variable from XML

How to extract id value from below xml using apigee?

sample:

<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:ns1="http://www.test.com/abc/xyz">
    <id>50905</id>
    <abc>test test</abc>
</A>

Tried below combination but didn't seems working.Please suggest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Id">
    <DisplayName>Extract-Id</DisplayName>
    <Source clearPayload="false">request</Source>
    <XMLPayload stopPayloadProcessing="false">
        <Namespaces>
            <Namespace prefix="ns1">http://www.test.com/abc/xyz</Namespace>
        </Namespaces>
        <Variable name="IdValue" type="nodeset">
            <XPath>/A/id</XPath>
        </Variable>
 	<!--<Variable name="IdValue" type="number">
            <XPath>/A/id</XPath>
        </Variable>
	<Variable name="IdValue" type="number">
            <XPath>number(/A/id)</XPath>
        </Variable>-->

    </XMLPayload>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>

Thanks

0 3 787
3 REPLIES 3

@vinay poreddy, I am able to extract both the variables "id" and "abc" using the below extract variable policy (using xpath). Pls check?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-fetch-values">  <DisplayName>EV-fetch-values</DisplayName>  <Properties/>  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>  <Source clearPayload="false">request</Source>  <XMLPayload stopPayloadProcessing="false">  <Namespaces>  <Namespace prefix="ns1">http://www.test.com/abc/xyz</Namespace>  </Namespaces>  <Variable name="id" type="number">  <XPath>/A/id</XPath>  </Variable>  <Variable name="abc" type="string">  <XPath>/A/abc</XPath>  </Variable>  </XMLPayload></ExtractVariables> 

It was issue at my end, as I didn't pass header as application/xml in postman which caused the issue.

@vinay poreddy, PFB assign message policy.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-Set-Resp-Obj">
    <DisplayName>AM-Set-Resp-Obj</DisplayName>
    <Properties/>
    <Set>
        <Headers/>
        <QueryParams/>
        <FormParams/>
        <Payload variablePrefix="@" variableSuffix="#" contentType="application/json">
{
    "id": "@id#",
    "abc": "@abc#"
}
        </Payload>
        <Path/>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo type="response" transport="http" createNew="false"/>
</AssignMessage>