Hi,

I did long time ago a test to add a child node to an xml root, you could
modify it.

public class XmlAggregator implements AggregationStrategy {
                
        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        
            Document oldBody =
oldExchange.getIn().getBody(org.w3c.dom.Document.class);
            Document newBody =
newExchange.getIn().getBody(org.w3c.dom.Document.class);
                
            NodeList list = newBody.getElementsByTagName("tag");
            
            Element element = (Element) list.item(0);

            Node copiedNode = oldBody.importNode(element, true);

            oldBody.getDocumentElement().appendChild(copiedNode);

            oldExchange.getIn().setBody(oldBody);

        return oldExchange;
    }
}

Hope it help.














--
View this message in context: 
http://camel.465427.n5.nabble.com/Aggregator-beyond-the-simple-string-example-tp5745012p5745055.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to