using mule variable value in xpath expression

我只是一个虾纸丫 提交于 2019-12-13 03:24:44

问题


I have a variable set as

<set-variable variableName="productIdvar" value="#[xpath://productId]" doc:name="Variable" />

On logging its coming right,

I want to use the value of the variable productIdvar in my xpath expression,

<when expression="//*[local-name()='itemid']=?" evaluator="xpath">

or

<when expression="#[xpath://*[local-name()='itemid']=?]">

What should i use in place of ? to get the value of the variable?

Thanks Rahul.


回答1:


The following expression should work for you.

<when expression="#[xpath('//*[local-name()=\'itemid\']').text == productIdvar ]">

This way you should be able to compare the result of the xpath with the "productIdVar" variable.

Hope this helps.




回答2:


<when expression="#[xpath('//*[local-name()=itemid]') == productIdvar ]">

Note that there are no quotation marks surrounding itemid in expression




回答3:


If your MEL gets a bit messy, try my mule-module-dxpath - an XPath transformer which dynamicaly resolves XPath variables.




回答4:


You can use XPATH3 and try something like this
#[xpath3('/products/validlity')== flowVars.productIdvar]
Xpath3 reference :- https://developer.mulesoft.com/docs/display/current/XPath



来源:https://stackoverflow.com/questions/18010219/using-mule-variable-value-in-xpath-expression

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!