-
-
2. Re: xpath and convertTo
sriram_imshriram Dec 2, 2009 2:47 PM (in response to davsclaus)Yes.
The problem i am not able to use both namesapce and return type.
I could use
xpath("expression",namespace)
or
xpath("expression",String.class)
Is there a way I could do both?
-
3. Re: xpath and convertTo
davsclaus Dec 3, 2009 2:02 AM (in response to sriram_imshriram)Ah got it
Maybe we should add a 3rd parameter so its easier in the future
I think you can do something like
// here we can pass in the return type as String etc. Namespaces ns = new Namespaces("c", "http://acme.com/cheese"); Expression exp = ns.xpath("expression", String.class); // and then use exp as the expression such as when(exp).to("direct:foo");
Let me know how goes.
-
4. Re: xpath and convertTo
sriram_imshriram Dec 3, 2009 11:28 AM (in response to davsclaus)I dont think this will solve my problem.
I need to extract a value from XML and add to my header.
Should I be using it as
setHeader("String").Expression
I know that its gonna be a string at runtime but compiletime?
-
5. Re: xpath and convertTo
janstey Dec 3, 2009 2:16 PM (in response to sriram_imshriram)Try this:
setHeader("foo", ns.xpath("expression", String.class)).
-
6. Re: xpath and convertTo
sriram_imshriram Dec 4, 2009 3:52 PM (in response to janstey)and that did the trick....
Thanks guys.
-
7. Re: xpath and convertTo
sriram_imshriram Dec 9, 2009 1:56 PM (in response to sriram_imshriram)Sorry for misleading you guys,
using the setHeader("").namespace.xpath("",String.class).
is always blank.....
Is there any better way to parse an xml for an element for writing my own processor and DOM parse it in there?
-
8. Re: xpath and convertTo
sriram_imshriram Dec 9, 2009 2:02 PM (in response to sriram_imshriram)sorry for having marked the question answered earlier
Edited by: sriram on Dec 10, 2009 12:32 AM
-
-
10. Re: xpath and convertTo
sriram_imshriram Dec 17, 2009 10:59 AM (in response to davsclaus)This is unusual, I was not even able to get it to compile....
Does this work only with Camel 2.0?
-
11. Re: xpath and convertTo
davsclaus Dec 17, 2009 11:09 AM (in response to sriram_imshriram)Could be as we have done a lot of work in 2.0 over 1.x.
-
12. Re: xpath and convertTo
sriram_imshriram Dec 17, 2009 11:15 AM (in response to davsclaus)I was using camel 1.6 and could not compile it....
Is there anyother solution that i could use in 1.6?
-
13. Re: xpath and convertTo
davsclaus Dec 17, 2009 2:25 PM (in response to sriram_imshriram)Compiles fine in 1.x, just that the mock component is improved in 2.0 so you had to change a bit there for the unit test. But the XPath stuff is 100% identical.