XPathCamel supports XPath To add an XPath expression to your routing rules its usually easiest to import the XPathBuilder import static org.apache.camel.builder.xpath.XPathBuilder.*; ... from("queue:foo").filter(xpath("//foo")).to("queue:bar") ExamplesHere is a simple example from("direct:start").filter( xpath("/person[@name='James']") ).to("mock:result"); Often the XML you are using has namespaces within it, so you can specify the namespaces to use in your XPath as follows in this example from("direct:start").filter( xpath("/c:person[@name='James']") .namespace("c", "http://acme.com/cheese")).to("mock:result"); If you have a standard set of namespaces you wish to work with and wish to share them across many different XPath expressions you can use the NamespaceBuilder as shown in this example // lets define the namespaces we'll need in our filters NamespaceBuilder ns = namespaceContext("c", "http://acme.com/cheese") .namespace("xsd", "http://www.w3.org/2001/XMLSchema"); from("direct:start").filter(ns.xpath("/c:person[@name='James']")).to("mock:result"); |