How to extract XPath Extractor answer in JMeter?

I got an answer like the following:

<response>
  <status code='200' server_time='xxx' />
  <tests>
    <test id='1' name='a!' status='Started' />
    <test id='2' name='bb!' status='New' />
    <test id='3' name='ccc!' status='New' />
    <test id='4' name='dddd!' status='New' />
  </tests>
</response>

I already added an Xpath extractor to the sampler:

Reference name: mytest
XPath Query: //test[@id='1']

But the return variable (mytest) is incorrect.

OUT.println(mytest) --> void

I am new to JMeter. What can I do to solve this problem?

+3
source share
2 answers

I already added an Xpath extractor to the sampler:

Reference name: mytest XPath Query:

//test[@id='1'] 

But the return variable (mytest) is wrong.

OUT.println(mytest) --> void

Obviously, the function println()displays the string value of the element test, and in the provided XML document, the testelements have no content, and their string value is an empty string.

Do you want :

/*/*/test[@id=1]/@name

and

/*/*/test[@id=1]/@status

name test , id 1.

status test , id 1.

+4

, . "Return entire XPath fragment instead of text content?"

+2

Source: https://habr.com/ru/post/1793827/


All Articles