1

I'm using JMeter and I need to get the value of <productid> from an Http API response (productid = 001)[see Http API response screenshot] and pass it to a jdbc request [see JDBC request screenshot]. How do I do this without using xpath?

Http API response:

enter image description here

JDBC request:

enter image description here

1
  • I'm not familiar with JMeter, so not posting as an answer, but can you use String.Contains() to find the productid tag position then String.Substring() to get the value? It's probably simpler than trying to get it via Regex (which a quick internet search says is supported by JMeter). There don't appear to be any plugins that would let you traverse an XML DOM without XPath
    – Kate Paulk
    Commented Jun 15, 2017 at 12:11

2 Answers 2

1

If for some reason you don't like XPath Extractor you can always switch to Regular Expression Extractor, the relevant configuration would be something like:

  • Reference Name: the same value you use in the XPath Extractor, i.e. id
  • Regular Expression: <productid>(.+?)</productid>
  • Template: $1$

You can refer it in the JDBC Request like:

  • SELECT * FROM PRODUCT WHERE id = ${id}

or maybe

  • SELECT * FROM PRODUCT WHERE ID = '${id}'

or use your approach but in this case you will need to know the data type of this ID column in the database.

1

What's wrong with XPath Extraction? Is there a specific reason you cannot use XPath?

You can use RegEx extractor, but keep in mind you are going to have to build a pretty well structured query to get the right value. XPath anticipates many results and puts them into an index array.

Without more information this question cannot be answered. - Why is that 90% of the questions in the SQA section?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.