Reputation: 1203
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. But when I put in ${myID} in the script, it is using the string "${myID}" instead of the actual value. 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.
So, why is it that ${myID} does not return the value?
Thanks in advance, Monte
Upvotes: 1
Views: 17358
Reputation: 12873
Use the single expression - <data xsi:type="soapenc:string">(.+?)</data>
- to get all the matches.
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.
Then you can refer required value via corresponding variable (myAnotherID_1 in your example).
JMeter Variables = true
to see all the variables generated upon extracting batch of values.Hope this helps.
Upvotes: 5