如何在mule中丰富xml节点值

时间:2015-05-06 17:32:57

标签: mule

input xml like below
<healthcare>
    <plans>
        <plan1>
            <planid>100</planid>
            <planname>medical</planname>
            <desc>medical</desc>
            <offerprice>3000</offerprice>
            <area>texas</area>
        </plan1>
        <plan2>
            <planid>101</planid>
            <planname>dental</planname>
            <desc>dental</desc>
            <offerprice>4000</offerprice>
            <area>texas</area>
        </plan2>
    </plans>
</healthcare>



 <set-variable variableName="newoffer" value="2000" doc:name="Variable" />
<foreach doc:name="For Each" collection="#[xpath3('//healthcare/plans', message.payload, 'NODESET' )]">
<enricher source="#[flowVars.newoffer]" target="#[xpath3('offerprice', payload 'STRING')]" >
<logger message="...#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</enricher>
<logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</foreach>

我希望将xml元素的offerprice值丰富为2000.但是上面没有这样做。任何人都有任何建议。主要的是我的预期输出如下所示。我是mule的新手。为了满足我的骡子要求,我们提供了许多建议。谢谢提前

<healthcare>
    <plans>
        <plan1>
            <planid>100</planid>
            <planname>medical</planname>
            <desc>medical</desc>
            **<offerprice>2000</offerprice>**
            <area>texas</area>
        </plan1>
        <plan2>
            <planid>101</planid>
            <planname>dental</planname>
            <desc>dental</desc>
            **<offerprice>2000</offerprice>**
            <area>texas</area>
        </plan2>
    </plans>
</healthcare>

1 个答案:

答案 0 :(得分:1)

要实现目标,请移除for-each / enricher元素,然后使用与Mule捆绑在一起的XSLT Transformer。这是将XML转换为XML的最佳选择。