Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 returns the text content of the elements that an XPath expression matches.

  • UPDATEXML replaces the element that an XPath expression matches with a new XML fragment, and returns the changed fragment.

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 status variable counts how often these functions have been used.

Other XML Features

This page is licensed: CC BY-SA / Gnu FDL

Last updated

Was this helpful?