Similar to EXISTSNODE(), EXTRACT() returns a set of nodes, if they 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 input XMLType variable. |
| XPath_string | The XPath string. |
| namespace_string | Optional. The default mapping or namespace mapping of the prefix. |
Examples
Assign an XML string to the c2 variable to create XML data. Call the EXTRACT method to extract nodes that meet the XPath expression 'a/b' from the c2 variable, and assign the extracted results to the t1 variable. Then, call the getstringval() method to obtain the string value of 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;
/