You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by horyna <ph...@centrum.cz> on 2013/04/25 14:03:23 UTC

How to replace a part of XML?

Hi,

i have a XML in exchange.body (
getExchanges().get(0).getIn().getBody(String.class) )

Has Camel some powerfull ability to change some elements in body?

Somethink like: .transform(body().replaceValueOfElement("<someelement>","new
value"))



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-replace-a-part-of-XML-tp5731535.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to replace a part of XML?

Posted by Bob Jolliffe <bo...@gmail.com>.
This is the type of task xslt is really well suited for.  Use an identity
template with a specific override, something like:

 <xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- replace text content of somelement -->
  <xsl:template match="/somewhere/someelement/text()" >
    <xsl:value-of select="new value" />
  <xsl:template>

</xsl:stylesheet>


On 25 April 2013 13:03, horyna <ph...@centrum.cz> wrote:

> Hi,
>
> i have a XML in exchange.body (
> getExchanges().get(0).getIn().getBody(String.class) )
>
> Has Camel some powerfull ability to change some elements in body?
>
> Somethink like:
> .transform(body().replaceValueOfElement("<someelement>","new
> value"))
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-replace-a-part-of-XML-tp5731535.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>