You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sv...@icarinae.com on 2010/04/07 21:49:39 UTC
Jmeter replace
Hi,
I have a xml request, that I have saved in a variable. There is
timestamp parameter that I need to update with system time.
I understand that i can get time using time function, however I have
to replace the value in the xml.
for example <timestamp>111</timestamp> to be replaced with
<timestamp>222<timestamp>
Is there any way I can replace that value in the xml that is saved ${MyVar}.
I tried using str = "${MyVar};
str=str.replaceAll("<timestamp>111</timestamp>",
"<timestamp>222<timestamp>");
in beanshell sampler, but it looks like " need to escaped etc..
Any other solution?
Thanks in advance..
Deepak Tiwari
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Jmeter replace
Posted by sv...@icarinae.com.
Thanks working now...
Quoting Deepak Shetty <sh...@gmail.com>:
> Hi
> You should probably use
> str = vars.get("MyVar");
> str=str.replaceAll("<timestamp>111</timestamp>",
> "<timestamp>222<timestamp>");
>
> regards
> deepak
>
>
>
> On Wed, Apr 7, 2010 at 1:01 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
>> if your code is literal then you havent closed the quote
>> str = "${MyVar}
>>
>> Check if there are beanshell errors. if not check that you dont have any
>> whitespace in the xml(or change the replace all to be a regexp that will
>> match)
>>
>> regards
>> deepak
>>
>>
>>
>> On Wed, Apr 7, 2010 at 12:49 PM, <sv...@icarinae.com> wrote:
>>
>>> Hi,
>>>
>>> I have a xml request, that I have saved in a variable. There is timestamp
>>> parameter that I need to update with system time.
>>>
>>> I understand that i can get time using time function, however I have to
>>> replace the value in the xml.
>>>
>>> for example <timestamp>111</timestamp> to be replaced with
>>> <timestamp>222<timestamp>
>>>
>>> Is there any way I can replace that value in the xml that is saved
>>> ${MyVar}.
>>>
>>> I tried using str = "${MyVar};
>>> str=str.replaceAll("<timestamp>111</timestamp>",
>>> "<timestamp>222<timestamp>");
>>> in beanshell sampler, but it looks like " need to escaped etc..
>>>
>>> Any other solution?
>>>
>>> Thanks in advance..
>>>
>>> Deepak Tiwari
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: Jmeter replace
Posted by Deepak Shetty <sh...@gmail.com>.
Hi
You should probably use
str = vars.get("MyVar");
str=str.replaceAll("<timestamp>111</timestamp>",
"<timestamp>222<timestamp>");
regards
deepak
On Wed, Apr 7, 2010 at 1:01 PM, Deepak Shetty <sh...@gmail.com> wrote:
> if your code is literal then you havent closed the quote
> str = "${MyVar}
>
> Check if there are beanshell errors. if not check that you dont have any
> whitespace in the xml(or change the replace all to be a regexp that will
> match)
>
> regards
> deepak
>
>
>
> On Wed, Apr 7, 2010 at 12:49 PM, <sv...@icarinae.com> wrote:
>
>> Hi,
>>
>> I have a xml request, that I have saved in a variable. There is timestamp
>> parameter that I need to update with system time.
>>
>> I understand that i can get time using time function, however I have to
>> replace the value in the xml.
>>
>> for example <timestamp>111</timestamp> to be replaced with
>> <timestamp>222<timestamp>
>>
>> Is there any way I can replace that value in the xml that is saved
>> ${MyVar}.
>>
>> I tried using str = "${MyVar};
>> str=str.replaceAll("<timestamp>111</timestamp>",
>> "<timestamp>222<timestamp>");
>> in beanshell sampler, but it looks like " need to escaped etc..
>>
>> Any other solution?
>>
>> Thanks in advance..
>>
>> Deepak Tiwari
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
Re: Jmeter replace
Posted by Deepak Shetty <sh...@gmail.com>.
if your code is literal then you havent closed the quote
str = "${MyVar}
Check if there are beanshell errors. if not check that you dont have any
whitespace in the xml(or change the replace all to be a regexp that will
match)
regards
deepak
On Wed, Apr 7, 2010 at 12:49 PM, <sv...@icarinae.com> wrote:
> Hi,
>
> I have a xml request, that I have saved in a variable. There is timestamp
> parameter that I need to update with system time.
>
> I understand that i can get time using time function, however I have to
> replace the value in the xml.
>
> for example <timestamp>111</timestamp> to be replaced with
> <timestamp>222<timestamp>
>
> Is there any way I can replace that value in the xml that is saved
> ${MyVar}.
>
> I tried using str = "${MyVar};
> str=str.replaceAll("<timestamp>111</timestamp>",
> "<timestamp>222<timestamp>");
> in beanshell sampler, but it looks like " need to escaped etc..
>
> Any other solution?
>
> Thanks in advance..
>
> Deepak Tiwari
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>