Using XPath Extractor
When it comes to dealing with XML or (X)HTML, JMeter comes bundled with an XPath Extractor component that allows you to extract matches from XML server responses using an XPath query language. For instance, extracting the title of a standard HTML structure can be accomplished using html/head/title
, getting all the paragraphs can be accomplished using body/p,
and so on. Moreover, when dealing with web services, particularly SOAP services, XMLs are used heavily as a means of exchange. This component is a perfect fit for handling such responses and extracting the needed information.
How to do it…
In this recipe, we will cover how to use XPath Extractor to handle XML server responses. Perform the following steps:
Launch JMeter.
Open the
ch2_xpath_extractor.jmx
test script located in thescripts/ch2
directory.Open the HTTP request labeled add_xpath_extractor_here.
Add XPath Extractor to it by navigating to Request | Add | Post Processor | XPath Extractor.
Fill in the values as...