Purpose
This function extracts a scalar value from an XML fragment based on an XPath.
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 to search for a node. The XPath must point to a single node (TEXT, ATTRIBUTE, or ELEMENT), and the node must have a single value. Otherwise, an error is returned. |
| 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
