Sometimes, the responses coming from the server are in XML format. Knowing how to handle such responses to extract the information needed by your scripts is an important aspect of building dynamic and robust scripts. Such scenarios might involve consuming web services or doing data manipulation to post to an external data source.
In this recipe, we will cover how to use JMeter to extract information from XML responses while consuming a freely available weather service. Perform the following steps:
Launch JMeter.
Add Thread Group to the new test plan by navigating to Test Plan | Add | Threads (Users) | Thread Group.
Add the HTTP Request sampler by navigating to Thread Group | Add | Sampler | HTTP Request.
Fill in its attributes in the following way:
Server Name or IP:
api.openweathermap.org
Method:
GET
Path:
/data/2.5/weather
Add the following request parameters to the request by clicking on the Add button:
Name
Value
q
London, UK
mode
XML
Add...