I have a Mule flow with a XML payload like:
<?xml version="1.0" encoding="utf-16"?>
<root type="1" name="blah">
<blablah value="10" desc="Material" />
</root>
I want to rename the "root" node and tried using the xml-to-dom-transformer and expression component. However, I have no idea how to do that.I tried something like this that did not help:
<expression-component><![CDATA[
node = message.payload.getRootElement();
node.renameNode = 'peo';
]]></expression-component>
Regards
Basically, I am suggesting the same approach as Anirban. But, a simpler XSLT.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
<newRoot>
<xsl:attribute name="type">
<xsl:value-of select="root/@type" />
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="root/@name" />
</xsl:attribute>
<xsl:copy-of select="root/node()" />
</newRoot>
</xsl:template>
</xsl:stylesheet>