Purpose
EXTRACTVALUE() extracts an XML fragment based on an XPath and returns the scalar value of the XML fragment.
Syntax
EXTRACTVALUE(XMLType_instance, XPath_string [, namespace_string ])
Parameters
| Parameter | Description |
|---|---|
| XMLType_instance | The XMLType data, which can be an XMLType column or an expression that returns XMLType data. |
| XPath_string | The XPath used for node search. This XPath must point to a single node (TEXT, ATTRIBUTE, or ELEMENT), and the node must have a single value. Otherwise, an error is reported. |
| namespace_string | The XML namespace. |
Return type
The return type is VARCHAR2(4000).
Examples
obclient> SELECT EXTRACTVALUE(c1, '/a/f:b', 'xmlns="ns1" xmlns:f="ns2"') as RES from xml_test where id = 6;
+------+
| RES |
+------+
| bbb1 |
+------+
1 row in set
obclient> SELECT EXTRACTVALUE(c1, '/a/h:b/text()', 'xmlns="ns1" xmlns:h="ns2"') as RES from xml_test where id = 6;
+------+
| RES |
+------+
| bbb1 |
+------+
1 row in set