...
Notice how we can reuse the namespace prefixes, foo in this case, in the XPath expression for easier namespace based XPath expressions!
Setting result type
The XPath expression will return a result type using native XML objects such as org.w3c.dom.NodeList
. But many times you want a result type to be a String. To do this you have to instruct the XPath which result type to use.
In Java DSL:
Code Block |
---|
xpath("/foo:person/@id", String.class)
|
In Spring DSL you use the resultType attribute to provide a fully qualified classname:
Code Block | ||||
---|---|---|---|---|
| ||||
<xpath resultType="java.lang.String">/foo:person/@id</xpath>
|
Examples
Here is a simple example using an XPath expression as a predicate in a Message Filter
...