Returns a collection of nodes if any nodes exist.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
EXTRACT(XMLType_instance, XPath_string [, namespace_string ])
Parameters
| Parameter | Description |
|---|---|
| XML_Type_instance | The xmltype variable. |
| XPath_string | The XPath path string. |
| namespace_string | The default namespace mapping or namespace mapping for a specified prefix (optional). |
Examples
The following example creates XML data by assigning an XML string to the c2 variable, extracts nodes that match the XPath expression 'a/b' from c2, assigns the extracted nodes to the t1 variable, and calls the getstringval() method to obtain the string representation of the XML data t1.
DECLARE
t1 xmltype;
c2 xmltype;
BEGIN
c2 := xmltype('<a><b>aaa</b><b>bbb</b></a>');
t1 := c2.extract('a/b');
dbms_output.put_line(t1.getstringval());
end;
/