The XPath Match assertion allows you to use an XPath expression to select content from the target request or response node and compare it with the value you expect.
Important
Important notes:
This assertion applies only to requests and responses with XML data in the body.
ReadyAPI cannot parse XML documents that contain the byte order mark (BOM) character.
This assertion is available in multiple ReadyAPI applications. Depending on the application, it validates the following data:
In... | Checks... | To learn more... |
---|---|---|
The request or response body. | ||
The response body. | See Security Assertions. | |
The request body. |
In the XPath Expression edit box, specify the XPath expression you want to use for this search or use the toolbar controls.
Important
To use the toolbar controls, run the request you want to validate at least once.
To create the expression automatically, click one of the following icons on the toolbar:
Option
Description
Call the Select XPath dialog. Use it to select a node from the last request or response and create an XPath expression for this node. See below.
Get the last request or response namespace and declare it.
In the Expected Result edit box, specify the value you are expecting to get. You can use the property expansion to point at a specific node.
Use these commands to select the value from the existing request or response:
Option
Description
Select Content
Add a property expansion to the result.
Select from Current
Get a value from the last response you have received (or the last request the virtual service has received).
If needed, use additional options to enhance the results you will get:
Option
Description
Allow Wildcards
Use an asterisk wildcard (
*
) for varying parts of the value.Note:
If you do not select this option, the assertion will fail on dynamic values.
Ignore Namespace Prefixes
To avoid name conflicts, XML elements use prefixes. A prefix points to a namespace that is associated with an element. Typically, the namespaces are represented by URIs. When this option is disabled, the assertion compares both prefixes and corresponding URIs. If this option is enabled, the assertion compares actual URIs that are declared for each prefix but ignores the prefix names.
Ignore XML comments
Skip XML comments during the comparison.
To test your assertion on the last response you have received (or the last request the virtual service has received), click Test.
To avoid typing the desired XPath expression manually, click and select the desired XML element or attribute in the subsequent dialog.

ReadyAPI will form an XPath expression that points to the selected item and will set the result of the last request or response as the expected result.
Important
If a node you are selecting contains a single child, ReadyAPI will try to get its text instead of the object itself.
The following expression gets the value of the
type
attribute of thepassword
element in thelogin
request://sam:login[1]/password[1]/@type
The following expression gets the string containing the session ID from the
loginResponse
response. It uses theconcat()
XPath function://sam:loginResponse[1]/concat('The user session ID is ',sessionid[1])
The following expression gets the value of the
description
subelement of theitem
element (with theid
attribute equal to1
) in theResponse
response.//sam:Response[1]/item[@id="1"]/description[1]
Add more assertions that validate XML content: