# How do I parse and validate an XML response?

> Validating an XML response in a load test is a way to validate the server response is what you expected. Here's how to do it in Loadster.

Source: https://loadster.com/faqs/parse-an-xml-response/

Loadster is a pretty good tool for load testing XML web services (SOAP, XML-RPC, some RESTful services, etc).

When you're testing an XML web service, you want to make sure the responses coming back are valid XML with the
right structure and data.

You can do this in Loadster with the "Validate with JavaScript" feature. Expand the **Add...** menu on the
step you want to validate, and select **Validate with JavaScript** from the menu.

_Figure: Adding a JavaScript validator_


This type of validator lets you write a custom JavaScript function to evaluate the response.

_Figure: Parsing an XML document and looking at a nested collection_


To parse the XML, use the `XML.parse` function. Since XML parsing is not standard in JavaScript the way
[JSON parsing](https://loadster.com/faqs/parse-a-json-response/) is, Loadster uses the [xmldoc](https://github.com/nfarina/xmldoc) parser.

Validation functions are expected to return a boolean value: `true` if the response is valid, and `false` if it's
invalid. In the above example, we're only considering the response valid if the response is a valid XML document
with a top-level collection `cars` that contains at least one `car` element in it.

You can read more about validation in Loadster, and other types of validators, in
[Validation Rules](https://loadster.com/manual/protocol-scripts/validation-rules/).

XML parsing also works in [Capturing Rules](https://loadster.com/manual/protocol-scripts/capturing-rules/).

