---
title: xpath function
description: Learn the syntax of the xpath function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath
---

# `xpath` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns values within the nodes of `xml` that match `xpath`.

## Syntax

```
xpath(xml, xpath)
```

## Arguments

* `xml`: A STRING expression of XML.
* `xpath`: A STRING expression that is a well formed XPath.

## Returns

An ARRAY of STRING.

The function raises an error if `xml` or `xpath` are malformed.

## Examples

```sql
> SELECT xpath('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>','a/b/text()');
 [b1, b2, b3]
```

## Related functions

* [`xpath_boolean` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_boolean.md)
* [`xpath_double` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_double.md)
* [`xpath_int` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_int.md)
* [`xpath_long` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_long.md)
* [`xpath_number` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_number.md)
* [`xpath_short` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_short.md)
* [`xpath_string` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/xpath_string.md)
