> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/connector-configuration/utils/xml/xpath.md). Agents can also search and read this documentation through its [MCP server](https://docs.appmixer.com/~gitbook/mcp).

# XPath

### Overview

The **XPath XML Extractor Component** extracts data from XML content using a specified XPath expression. This allows precise retrieval of elements, attributes, or values from structured XML data.

### Usage

This component takes an XML string as input and applies an XPath query to extract specific information.

#### Input Ports

| Port | Description                                                   |
| ---- | ------------------------------------------------------------- |
| `in` | Accepts an XML string and an XPath expression for processing. |

**Input Properties**

| Property | Type     | Description                                                 |
| -------- | -------- | ----------------------------------------------------------- |
| `xml`    | `string` | XML content to process.                                     |
| `xpath`  | `string` | XPath expression for selecting elements. E.g., `'//title'`. |

#### Output Ports

| Port  | Description                                                         |
| ----- | ------------------------------------------------------------------- |
| `out` | Provides the extracted data from XML based on the XPath expression. |

**Output Properties**

| Property | Type     | Description                                         |
| -------- | -------- | --------------------------------------------------- |
| `result` | `string` | Extracted data based on the given XPath expression. |

#### Processing Logic

1. **Parse XML Input**: Converts the input XML string into a DOM object.
2. **Apply XPath Expression**: Executes the XPath query on the parsed XML.
3. **Format Extracted Data**: If multiple matches are found, results are concatenated into a single string.
4. **Send Output**: The extracted data is emitted through the `out` port.

### Notes

* **Flexible Queries**: Supports selecting elements, attributes, and text nodes via XPath.
* **Handles Multiple Matches**: When multiple elements match the XPath, results are concatenated.
* **Efficient XML Parsing**: Uses `xmldom` and `xpath` libraries for reliable parsing and selection.

This component provides a powerful way to extract and manipulate XML data using XPath expressions, making it highly useful for XML-based workflows.


---

# 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.appmixer.com/connector-configuration/utils/xml/xpath.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.
