How to use xpath in camel-context.xml to check if a particular node exists or not

I am trying to develop a content based camel application. This application will look at the src / data folder to see if there is a SOAP request file with node <e2d:getOrderDetaiRequest>

, then this file will be copied to target / message, otherwise the file will be copied to target / other.

Do you know how to use xpath (or any other tools) to check for this condition (I prefer using camel-context.xml file)?

Here is my camel context

        <from uri="file://c:/src/data?noop=true"/>
                <to uri="file://c:/target/message"/>
            <to uri="file://c:/target/other"/>


And here is an example from two different SOAP requests

<soapenv:Envelope xmlns:soapenv="" xmlns:e2d="">



<soapenv:Envelope xmlns:soapenv="" xmlns:lsr="">



source to share

1 answer

When using xpath and your xml has namespaces like your SOAP message, then you have to use namespaces in the xpath expression too.

The Camel docmentation has some details:

Using XML DSL in Camel, you can declare namespace in XML tag directly, like camelContext etc.

<camelContext xmlns="" e2d="">


But remember that XPaths can be a little tricky to work properly. This is why we added logNamespaces in Camel 2.10. See details at the bottom of this page:



All Articles