> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/apis/assertion/xmlpath.md).

# XMLPath

This is a pre-built action available under **@Assertion**. This Action validates whether the value extracted from the XML response using an XMLPath expression matches the expected value or regex pattern. The action supports different match types to validate the extracted value.

## Syntax

**Input Value**: `<XMLPath expression>;<Expected value (optional) or regex pattern>;<Match type (Optional)>`

{% hint style="info" %}
**Note**: You can generate expressions using the [Assertion expression builder](https://docs.avoautomation.com/avo-assure/actions/apis/assertion/jsonpath-match/assertion-expression-builder.md) available for the Response XML Body. The generated expression can be used directly as the input for the XPath match action.
{% endhint %}

| Argument                                     | Description                                                                                                  |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| <p>\<XMLPath expression> <br>(Required) </p> | Specify the XMLPath expression used to extract the value from the XML response.                              |
| \<Expected value /regex pattern (optional)>  | Specify the expected value or regex pattern to compare with the extracted value.                             |
| \<Match type (optional)>                     | Specify the type of matching to perform between the extracted value and the expected value or regex pattern. |

**Output Value**: `<Actual value(optional)>;<Keyword Status(optional)>`

| Argument                                 | Description                                                                                             |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| <p>\<Actual value> <br>(optional) </p>   | The actual value stores the value extracted from the XML response using the specified XPath expression. |
| <p>\<Keyword Status> <br>(optional) </p> | The keyword status variable stores the status as **True** or **False**.                                 |

### Example 1: Validating an XML Value

In this example, we verify that a value extracted from the XML response matches the expected value.

* **Action:** XMLPath
* **Input Value:** /company/name;TechNova
  * The first part (**/company/name**) specifies the XMLPath expression used to extract the value from the XML response.
  * The second part (**TechNova**) specifies the expected value.
* **Output Value:** {Actual Value};{Keyword Status}
  * The first output variable **{Actual Value}** stores the value extracted from the XML response.
  * If the second output variable **{Keyword Status}** is defined, it stores the assertion result with the following possible values:
    * **True:** If the extracted value matches the expected value.
    * **False:** If the extracted value does not match the expected value.
* **Logical Explanation:** The **XMLPath** action evaluates the XMLPath expression (**/company/name**) against the XML response and extracts the value (For example, **TechNova**). The action then compares the extracted value with the expected value (For Example, **TechNova**). If both values match, the variable **{Keyword Status}** stores the result as **True**.

### Example 2: Validating an XML Value Using a Regex Pattern

In this example, we verify that an employee ID extracted from the XML response matches the specified regex pattern.

* **Action:** XMLPath
* **Input Value:** //employee/id;EMP\[0-9]+;Regex
  * The first part (**//employee/id**) specifies the XMLPath expression used to extract the employee ID from the XML response.
  * The second part (**EMP\[0-9]+**) specifies the regex pattern used to validate the extracted value.
  * The third part (**Regex**) specifies the match type.
* **Output Value:** {Actual Value};{Keyword Status}
  * The first output variable **{Actual Value}** stores the value extracted from the XML response using the specified XMLPath expression. For example, if the extracted employee ID is **EMP123**, **{Actual Value}** stores **EMP123**.
  * If the second output variable **{Keyword Status}** is defined, it stores the assertion result with the following possible values:
    * **True:** If the extracted value matches the specified regex pattern.
    * **False:** If the extracted value does not match the specified regex pattern.
* **Logical Explanation:** The **XMLPath** action evaluates the XMLPath expression (**//employee/id**) against the XML response and extracts the employee ID (For example, **EMP123**). The extracted value is stored in the **{Actual Value}** variable. The action then validates the extracted value against the regex pattern (**EMP\[0-9]+**). Since **EMP123** matches the specified pattern, the variable **{Keyword Status}** stores the result as **True**.

## **XMLPath Expressions**

| XMLPath Expression | Meaning         | Example                      | Purpose                                       | Returns                 |
| ------------------ | --------------- | ---------------------------- | --------------------------------------------- | ----------------------- |
| /                  | Root path       | /employees                   | Selects the root element                      | Root element            |
| //                 | Descendant path | //employee                   | Selects matching elements anywhere in the XML | Matching elements       |
| .                  | Current node    | .                            | Selects the current node                      | Current node            |
| ..                 | Parent node     | //employee/name/..           | Selects the parent of the current node        | Parent node             |
| @                  | Attribute       | //employee/@id               | Selects an attribute                          | Attribute value         |
| \*                 | Wildcard        | //employee/\*                | Selects all child elements                    | Matching child elements |
| text()             | Text node       | //employee/name/text()       | Selects the text content of an element        | Text value              |
| node()             | Any node        | //employee/node()            | Selects all types of child nodes              | Matching nodes          |
| \[condition]       | Predicate       | //employee\[department='IT'] | Selects elements that meet a condition        | Matching elements       |
| \[1]               | First element   | //employee\[1]               | Selects the first matching element            | First element           |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avoautomation.com/avo-assure/actions/apis/assertion/xmlpath.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
