The EXISTSNODE function determines whether the XML variable contains a node at the specified XPath path.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
EXISTSNODE(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 specified by a prefix (optional). |
Return value
If the specified node exists, 1 is returned.
If the specified node does not exist, 0 is returned.
Examples
The following example creates an XMLType variable c2 and assigns an XML string to it. Then, it calls the EXISTSNODE method of c2 to check whether there is a node at the XPath path "a/b" and assigns the result to the variable t1. Finally, it uses the dbms_output.put_line function to output the value of t1 to the console.
obclient> DECLARE
t1 int;
c2 xmltype;
BEGIN
c2 := xmltype('<a><b>aaa</b><b>bbb</b></a>');
t1 := c2.existsnode('a/b');
dbms_output.put_line(t1);
end;
/
Query OK, 1 row affected (0.153 sec)