[英]How to extract certain values using regular expression extractor in JMeter?
In the case where I have two identical tags and identical attributes and the only difference is the value, how can I extract the second one? 如果我有两个相同的标签和相同的属性,唯一的区别是值,我该如何提取第二个?
<data xsi:type="soapenc:string">0</data>
<data xsi:type="soapenc:string">1</data>
I have tried doing the followings. 我尝试了以下操作。
<data xsi:type="soapenc:string">0</data><data xsi:type="soapenc:string">(.+?)</data>
And assign the value to myID. 并将值分配给myID。 But when I put in ${myID} in the script, it is using the string "${myID}" instead of the actual value.
但是,当我在脚本中放入$ {myID}时,它使用的是字符串“ $ {myID}”而不是实际值。 Is it that the extraction not working?
是提取不起作用吗? Or do I need to use a different variable for it?
还是我需要使用其他变量?
I have a different sampler where I have only one tag. 我有一个不同的采样器,其中只有一个标签。 For example,
例如,
<data xsi:type="soapenc:string">0</data>
When I do, 当我做,
<data xsi:type="soapenc:string">(.+?)</data>
and assign to myAnotherID, I can use ${myAnotherID} and the value would be used in the script. 并分配给myAnotherID,我可以使用$ {myAnotherID},该值将在脚本中使用。
So, why is it that ${myID} does not return the value? 那么,为什么$ {myID}不返回值呢?
Thanks in advance, Monte 在此先感谢,蒙特
Use the single expression - <data xsi:type="soapenc:string">(.+?)</data>
- to get all the matches. 使用单个表达式-
<data xsi:type="soapenc:string">(.+?)</data>
-获得所有匹配项。
If there are more than one match jmeter will generate specific variables for each match, based on the variable name to which you are trying to extract - like refName_N
: myAnotherID_1, myAnotherID_2, ..., myAnotherID_N in your case. 如果有多个匹配项,jmeter将根据您尝试提取的变量名称为每个匹配项生成特定的变量-如
refName_N
:您的案例中的myAnotherID_1,myAnotherID_2,...,myAnotherID_N。
Then you can refer required value via corresponding variable (myAnotherID_1 in your example). 然后,您可以通过相应的变量(示例中的myAnotherID_1)来引用所需的值。
JMeter Variables = true
to see all the variables generated upon extracting batch of values. JMeter Variables = true
以查看提取一批值时生成的所有变量。 Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.