camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: release 2.3.0 XPathBuilder.xpath evaluate gives different result
Date Fri, 28 May 2010 10:42:35 GMT
On Fri, May 28, 2010 at 12:39 PM, larsa <lars.andersson@jayway.com> wrote:
>
> Hi
>
> In release 2.3.0 given the following XML
>
> "<foo><bar>cheese</bar></foo>"
> XPathBuilder.xpath("foo/bar").evaluate(exchange, String.class);
> returns  "<bar>cheese</bar>"
>
> See test below.
> Is this the correct behavior or a bug?
>

Yes its correct now. As you have selected the bar node.
If you only want the content of the node you have to tell XPath that using

/foo/bar/text()

For example suppose the tag have attributes etc, then those will be included now

<bar id="2">cheese</bar>

And if you want the id you can do

/foo/bar/@id



>
> Regards Lars
>
>
> In Camel 2.2.0 the following test is true
>
>      public void testXpath(){
>
>                Exchange exchange = new DefaultExchange(context);
>                exchange.getIn().setBody("<foo><bar>cheese</bar></foo>");
>
>                String value =
> XPathBuilder.xpath("foo/bar").evaluate(exchange, String.class);
>
>                Assert.assertEquals("cheese", value);
>      }
>
> In Camel 2.3.0 the following test is true
>
>
>      public void testXpath(){
>
>                Exchange exchange = new DefaultExchange(context);
>                exchange.getIn().setBody("<foo><bar>cheese</bar></foo>");
>
>                String value =
> XPathBuilder.xpath("foo/bar").evaluate(exchange, String.class);
>
>                Assert.assertEquals("<bar>cheese</bar>", value);
>      }
> --
> View this message in context: http://old.nabble.com/release-2.3.0-XPathBuilder.xpath-evaluate-gives-different-result-tp28705231p28705231.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message