'can't extract value from xpath-extract using mule variables
I have a set LocationProperties variable as its Location-465697646-800339871 value. Based on the value of a variable, I want to select a node in the payload.
Mule 3:
xpath3('//DTOLocation[@id=\'' + flowVars.LocationProperties.LocationRef + '\'][1]/DTOLocationDetail[@DetailTypeCd=\'CommercialPropertyLocationDetail\'][1]/@ProtectionClassCd',flowVars.domPayload)
xpath3('//DTOLocation[@id=' + flowVars.LocationProperties.LocationRef + '][1]/@LocationCounterNumber',flowVars.domPayload)
Mule 4 flow:
<flow name="var_xpath_testFlow" doc:id="406270fb-17e7-48e9-a33a-f7a0197f8e05" >
<http:listener doc:name="Listener" doc:id="662f2277-859f-4516-974b-de7cceeb5b40" config-ref="HTTP_Listener_config" path="/vartest"/>
<set-variable value="#[payload]" doc:name="Set domPayload" doc:id="2495ac98-b976-41e0-9dcf-398574e54ffa" variableName="domPayload"/>
<set-variable value="Location-465697646-800339871" doc:name="Set Variable" doc:id="12370458-bb32-4709-b509-acc1e5f50b94" variableName="LocationProperties"/>
<xml-module:xpath-extract xpath="#["/DTOApplication/DTOLocation[@id='" ++ vars.LocationProperties ++ "'][1]"/DTOLocationDetail[@DetailTypeCd='CommercialPropertyLocationDetail'][1]/@ProtectionClassCd]" target="xvalue1" config-ref="XML_Config"/>
<xml-module:xpath-extract xpath="#["/DTOApplication/DTOLocation[@id='" ++ vars.LocationProperties ++ "'][1]"/@LocationCounterNumber]" config-ref="XML_Config" target="xvalue2"/>
<logger level="INFO" doc:name="Logger" doc:id="f495b0bf-f8cb-43be-b4d9-d069758e4028" message="#[vars.xvalue]"/>
</flow>
Input payload: https://github.com/Manikandan99/rate-dtostep/blob/master/request.xml
Expected output is the variable :
xvalue1 returns 3,
xvalue2 returns 1.
If I give values directly in xpath, it's work.
When I'm trying to use variables inside an xpath,it throws error like : https://github.com/Manikandan99/rate-dtostep/blob/master/xapth_error.txt
How to extract value using variables in XPath Mule 4?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
