You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Pradeep_s83 <sr...@gmail.com> on 2009/12/10 18:29:22 UTC

Help needed with xpath

?xml version="1.0"?>
<OrderItems>
<ItemId>12122</ItemId>
<Items>
 <ItemDesc>
  <Name>fdf</Name>
   <Desc>dsfdsfdsf</Desc>
   <OrderItemId>0123</OrderItemId>
  </ItemDesc>
 <ItemDesc>
  <Name>gbgfb</Name>
  <Desc>654654</Desc>
  <OrderItemId>123</OrderItemId>
 </ItemDesc>
</Items>
</OrderItems>

This is my response for a httprequest.It can contain multiple OrderItemId
tags.I need to get the data inside all the OrderItemId tags and append each
value using a comma.
If order item ids A AND B are returned i need to form A,B.
How can i use Xpath for achieving the same?

-- 
View this message in context: http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


RE: Help needed with xpath

Posted by "Turkel, David" <dt...@acumensolutions.com>.
//OrderItemId is the XPath syntax.

-----Original Message-----
From: Pradeep_s83 [mailto:sreekumar.pradeep@gmail.com] 
Sent: Thursday, December 10, 2009 12:29 PM
To: jmeter-user@jakarta.apache.org
Subject: Help needed with xpath


?xml version="1.0"?>
<OrderItems>
<ItemId>12122</ItemId>
<Items>
 <ItemDesc>
  <Name>fdf</Name>
   <Desc>dsfdsfdsf</Desc>
   <OrderItemId>0123</OrderItemId>
  </ItemDesc>
 <ItemDesc>
  <Name>gbgfb</Name>
  <Desc>654654</Desc>
  <OrderItemId>123</OrderItemId>
 </ItemDesc>
</Items>
</OrderItems>

This is my response for a httprequest.It can contain multiple
OrderItemId
tags.I need to get the data inside all the OrderItemId tags and append
each
value using a comma.
If order item ids A AND B are returned i need to form A,B.
How can i use Xpath for achieving the same?

-- 
View this message in context:
http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Help needed with xpath

Posted by Pradeep_s83 <sr...@gmail.com>.
Hi Deepak,
Thank you very much for your help and support:-)

Deepak Shetty wrote:
> 
> Hi
> Beanshell (almost) same as java
> 
> ThreadGroup
> +Request Returning XML
> ++XPATH extractor (ref name=itemIds,
> query=/OrderItems/Items/ItemDesc/OrderItemId)
> ++BeanShell Listener
> +Debug Sampler
> +View Results Tree
> 
> Paste the following into the Beanshell listener (Pseudoish code, assumes
> there is always 1 id, doesnt check errors etc)
> 
> int count = Integer.parseInt(vars.get("itemIds_matchNr")); //itemIds is
> the
> ref name in xpath extractor, if you change it, change this
> StringBuffer sb = new StringBuffer();
> for(int i=1;i<=count;i++){
>     sb.append(vars.get("itemIds_" + i)); //itemIds is the ref name in
> xpath
> extractor, if you change it, change this
>      if(i!=count){
>        sb.append(',');
>     }
> }
> vars.put("finalResult",sb.toString());
> 
> 
> The final result is available in ${finalResult} or
> vars.get("finalResult");
> 
> regards
> deepak
> 
> On Thu, Dec 10, 2009 at 10:49 AM, Pradeep_s83
> <sr...@gmail.com>wrote:
> 
>>
>> Can you please suggest how to concatenate the values using bean sheel
>> scripting?
>>
>> Deepak Shetty wrote:
>> >
>> > select /OrderItems/Items/ItemDesc/OrderItemId and then concatenate
>> using
>> > Beanshell is one option.
>> > The other option would have been to use XPATH 2.0 and the string-join
>> > function, but I dont think JMeter supports that (unless someone else
>> knows
>> > how to get Jmeter to recognise 2.0 functions)
>> >
>> > regards
>> > deepak
>> >
>> > On Thu, Dec 10, 2009 at 9:29 AM, Pradeep_s83
>> > <sr...@gmail.com>wrote:
>> >
>> >>
>> >> ?xml version="1.0"?>
>> >> <OrderItems>
>> >> <ItemId>12122</ItemId>
>> >> <Items>
>> >>  <ItemDesc>
>> >>  <Name>fdf</Name>
>> >>   <Desc>dsfdsfdsf</Desc>
>> >>   <OrderItemId>0123</OrderItemId>
>> >>  </ItemDesc>
>> >>  <ItemDesc>
>> >>  <Name>gbgfb</Name>
>> >>  <Desc>654654</Desc>
>> >>  <OrderItemId>123</OrderItemId>
>> >>  </ItemDesc>
>> >> </Items>
>> >> </OrderItems>
>> >>
>> >> This is my response for a httprequest.It can contain multiple
>> OrderItemId
>> >> tags.I need to get the data inside all the OrderItemId tags and append
>> >> each
>> >> value using a comma.
>> >> If order item ids A AND B are returned i need to form A,B.
>> >> How can i use Xpath for achieving the same?
>> >>
>> >> --
>> >> View this message in context:
>> >> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
>> >> Sent from the JMeter - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26732525.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Help-needed-with-xpath-tp26731317p26748847.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Help needed with xpath

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
Beanshell (almost) same as java

ThreadGroup
+Request Returning XML
++XPATH extractor (ref name=itemIds,
query=/OrderItems/Items/ItemDesc/OrderItemId)
++BeanShell Listener
+Debug Sampler
+View Results Tree

Paste the following into the Beanshell listener (Pseudoish code, assumes
there is always 1 id, doesnt check errors etc)

int count = Integer.parseInt(vars.get("itemIds_matchNr")); //itemIds is the
ref name in xpath extractor, if you change it, change this
StringBuffer sb = new StringBuffer();
for(int i=1;i<=count;i++){
    sb.append(vars.get("itemIds_" + i)); //itemIds is the ref name in xpath
extractor, if you change it, change this
     if(i!=count){
       sb.append(',');
    }
}
vars.put("finalResult",sb.toString());


The final result is available in ${finalResult} or vars.get("finalResult");

regards
deepak

On Thu, Dec 10, 2009 at 10:49 AM, Pradeep_s83
<sr...@gmail.com>wrote:

>
> Can you please suggest how to concatenate the values using bean sheel
> scripting?
>
> Deepak Shetty wrote:
> >
> > select /OrderItems/Items/ItemDesc/OrderItemId and then concatenate using
> > Beanshell is one option.
> > The other option would have been to use XPATH 2.0 and the string-join
> > function, but I dont think JMeter supports that (unless someone else
> knows
> > how to get Jmeter to recognise 2.0 functions)
> >
> > regards
> > deepak
> >
> > On Thu, Dec 10, 2009 at 9:29 AM, Pradeep_s83
> > <sr...@gmail.com>wrote:
> >
> >>
> >> ?xml version="1.0"?>
> >> <OrderItems>
> >> <ItemId>12122</ItemId>
> >> <Items>
> >>  <ItemDesc>
> >>  <Name>fdf</Name>
> >>   <Desc>dsfdsfdsf</Desc>
> >>   <OrderItemId>0123</OrderItemId>
> >>  </ItemDesc>
> >>  <ItemDesc>
> >>  <Name>gbgfb</Name>
> >>  <Desc>654654</Desc>
> >>  <OrderItemId>123</OrderItemId>
> >>  </ItemDesc>
> >> </Items>
> >> </OrderItems>
> >>
> >> This is my response for a httprequest.It can contain multiple
> OrderItemId
> >> tags.I need to get the data inside all the OrderItemId tags and append
> >> each
> >> value using a comma.
> >> If order item ids A AND B are returned i need to form A,B.
> >> How can i use Xpath for achieving the same?
> >>
> >> --
> >> View this message in context:
> >> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26732525.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: Help needed with xpath

Posted by Pradeep_s83 <sr...@gmail.com>.
Can you please suggest how to concatenate the values using bean sheel
scripting?

Deepak Shetty wrote:
> 
> select /OrderItems/Items/ItemDesc/OrderItemId and then concatenate using
> Beanshell is one option.
> The other option would have been to use XPATH 2.0 and the string-join
> function, but I dont think JMeter supports that (unless someone else knows
> how to get Jmeter to recognise 2.0 functions)
> 
> regards
> deepak
> 
> On Thu, Dec 10, 2009 at 9:29 AM, Pradeep_s83
> <sr...@gmail.com>wrote:
> 
>>
>> ?xml version="1.0"?>
>> <OrderItems>
>> <ItemId>12122</ItemId>
>> <Items>
>>  <ItemDesc>
>>  <Name>fdf</Name>
>>   <Desc>dsfdsfdsf</Desc>
>>   <OrderItemId>0123</OrderItemId>
>>  </ItemDesc>
>>  <ItemDesc>
>>  <Name>gbgfb</Name>
>>  <Desc>654654</Desc>
>>  <OrderItemId>123</OrderItemId>
>>  </ItemDesc>
>> </Items>
>> </OrderItems>
>>
>> This is my response for a httprequest.It can contain multiple OrderItemId
>> tags.I need to get the data inside all the OrderItemId tags and append
>> each
>> value using a comma.
>> If order item ids A AND B are returned i need to form A,B.
>> How can i use Xpath for achieving the same?
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Help-needed-with-xpath-tp26731317p26732525.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Help needed with xpath

Posted by Deepak Shetty <sh...@gmail.com>.
select /OrderItems/Items/ItemDesc/OrderItemId and then concatenate using
Beanshell is one option.
The other option would have been to use XPATH 2.0 and the string-join
function, but I dont think JMeter supports that (unless someone else knows
how to get Jmeter to recognise 2.0 functions)

regards
deepak

On Thu, Dec 10, 2009 at 9:29 AM, Pradeep_s83 <sr...@gmail.com>wrote:

>
> ?xml version="1.0"?>
> <OrderItems>
> <ItemId>12122</ItemId>
> <Items>
>  <ItemDesc>
>  <Name>fdf</Name>
>   <Desc>dsfdsfdsf</Desc>
>   <OrderItemId>0123</OrderItemId>
>  </ItemDesc>
>  <ItemDesc>
>  <Name>gbgfb</Name>
>  <Desc>654654</Desc>
>  <OrderItemId>123</OrderItemId>
>  </ItemDesc>
> </Items>
> </OrderItems>
>
> This is my response for a httprequest.It can contain multiple OrderItemId
> tags.I need to get the data inside all the OrderItemId tags and append each
> value using a comma.
> If order item ids A AND B are returned i need to form A,B.
> How can i use Xpath for achieving the same?
>
> --
> View this message in context:
> http://old.nabble.com/Help-needed-with-xpath-tp26731317p26731317.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>