On Fri, Jul 24, 2015 at 2:11 PM, Jakub Korab
<[email protected]> wrote:
> Try setting the return type from the xpath expression:
>
> .setHeader("isbns", xpath("/order//isbn/text()", List.class))
>
I wonder if a xpath with /text() works for a NodeList type, eg you
will end up with a NodeList of 2 text values. Though it would feel
natural to do so.
> Jakub
>
>
> On 24/07/15 13:05, Markus Eisele wrote:
>>
>> Hi,
>>
>> I was trying to convert a bunch of //text() Nodes selected via XPath
>> into a List<String> and keep getting a ClassCastException.
>>
>> My input xml:
>>
>> <isbn>9781617290450</isbn>
>> <isbn>9780132360280</isbn>
>>
>> The route
>>
>> .setHeader("isbns", xpath("/order//isbn/text()"))
>> .bean(orderService, "handleOrder(${header[isbns]})")
>>
>> The Bean Method:
>>
>> public void handleOrder(List<String> orders) {
>>
>> orders.stream().forEach((o) -> {
>> LOGGER.log(Level.INFO, "Order: {0}", o);
>> });
>>
>>
>> Thanks for a hint.
>>
>> Cheers,
>> Markus
>
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2