An easy way to get the value is to use XPath Language . This will allow you to extract the necessary data and install it somewhere (header, body, ...). Here's how to set parameter2 header with value:
<setHeader headerName="parameter2"> <xpath resultType="java.lang.String"> /userProfiles/userProfile/userProfileAttributes/userProfileAttribute[2]/@value </xpath> </setHeader>
Using Java DSL
An example of using Java DSL and setting the message body:
final Namespaces ns = new Namespaces("c", "http://www.mycompany.com/AEContext/xmldata"); // existing code from(...) .setBody( ns.xpath( "/c:userProfiles/userProfile/userProfileAttributes/userProfileAttribute[2]/@value", String.class) ) .to(...);
source share