문제

I'm new to Mule, please guide me how to insert new tag inside the XML structure using Mule Expression Language (MEL).Need to insert B tag in the below XML structure

<Test>
<A>table 1</A>
<C>table 3</C>
</Test> 

Thanks in Advance.

도움이 되었습니까?

해결책

My dom4j fu is limited but here is what I came up with:

<mulexml:xml-to-dom-transformer returnClass="org.dom4j.Document" />

<expression-component><![CDATA[
  bNode = message.payload.rootElement.addElement('B');
  bNode.text = 'table 2';
  message.payload.rootElement.elements().add(1, bNode.detach());
]]></expression-component>

<mulexml:dom-to-xml-transformer />

This works fine with Mule 3.4.0.

다른 팁

Use a Data Weave component as below:

%dw 1.0
%output application/xml
%var myValue='MyValue'
%var B=''
---

myoutput:{
    data: payload.Test ++ B:myValue

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top