Evaluating XPath Expressions in Custom Processors in Apache Camel

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.builder.xml.Namespaces;

public final class SampleRouteBuilder extends RouteBuilder {
  private static final Namespaces NS = new Namespaces("sample", "http://fernandoribeiro.eti.br/sample/camel");

  @Override
  public void configure() throws Exception {
    from(...).process(new Processor() {

      public void process(final Exchange exchange) {
        final String str = (String) NS.xpath("/sample:Element", String.class).evaluate(exchange);

        ...
      }

    });
  }

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s