> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/special-functions/xml-functions.md).

# XML Functions

XML functions in MariaDB Server: EXTRACTVALUE() reads text from an XML fragment with an XPath expression, and UPDATEXML() replaces part of it.

MariaDB Server provides two functions for working with XML fragments stored as strings. Both take an XPath expression that selects the part of the fragment to work on.

* [EXTRACTVALUE](/docs/server/reference/sql-functions/special-functions/xml-functions/extractvalue.md) returns the text content of the elements that an XPath expression matches.
* [UPDATEXML](/docs/server/reference/sql-functions/special-functions/xml-functions/updatexml.md) replaces the element that an XPath expression matches with a new XML fragment, and returns the changed fragment.

```sql
SELECT ExtractValue('<a><b>x</b><b>y</b></a>', '/a/b[2]') AS extracted,
       UpdateXML('<a><b>x</b></a>', '/a/b', '<c>z</c>') AS updated;
```

```
+-----------+-----------------+
| extracted | updated         |
+-----------+-----------------+
| y         | <a><c>z</c></a> |
+-----------+-----------------+
```

The [Feature\_xml](/docs/server/server-management/variables-and-modes/server-status-variables.md#feature_xml) status variable counts how often these functions have been used.

## Other XML Features

* [XMLTYPE](/docs/server/reference/data-types/string-data-types/xmltype.md) is a data type for storing XML data, available from MariaDB 12.3.
* [LOAD XML](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/load-data-into-tables-or-index/load-xml.md) reads data from an XML file into a table.
* The [CONNECT XML table type](/docs/server/server-usage/storage-engines/connect/connect-table-types/connect-xml-table-type.md) accesses an XML file as a table.
* The `--xml` option of the [mariadb](/docs/server/clients-and-utilities/mariadb-client/mariadb-command-line-client.md#x-xml) client and of [mariadb-dump](/docs/server/clients-and-utilities/backup-restore-and-import-clients/mariadb-dump.md#x-xml) produces XML output.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>
