The GETCHILDNODES function returns all direct child nodes of a specified node n, presenting the result as an ordered list (DBMS_XMLDOM.DOMNODELIST), but excluding descendant nodes at deeper levels.
Applicability
This content applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL-compatible mode.
Note
For V4.4.2, this subprogram is available starting with OceanBase Database V4.4.2 BP2.
Syntax
DBMS_XMLDOM.getChildNodes (
node IN DBMS_XMLDOM.DOMNODE);
Parameters
Parameter |
Description |
|---|---|
| node | The DBMS_XMLDOM.DOMNODE handle for which to obtain child nodes. Typically a document node or element node with child nodes. The supported types depend on the current implementation. |
Return value
A DBMS_XMLDOM.DOMNODELIST consisting solely of direct child nodes.
Usage instructions
When traversing the returned list, use this function in conjunction with GETLENGTH and ITEM. To access deeper nodes, recursively call this function for child nodes.
Examples
This example uses the DBMS_XMLPARSER system package to parse an XML document and obtain a DOMDOCUMENT handle. Then, it uses the DBMS_XMLDOM system package to obtain a DOMNODELIST handle for the XML document and retrieve the list of child nodes of the first element in the list:
-- Declare parser and document handle variables
DECLARE
p DBMS_XMLPARSER.PARSER;
doc DBMS_XMLDOM.DOMDOCUMENT;
n DBMS_XMLDOM.DOMNODE;
nl DBMS_XMLDOM.DOMNODELIST;
BEGIN
-- Create a parser instance
p := DBMS_XMLPARSER.NEWPARSER;
-- Parse the XML document in the parser.
DBMS_XMLPARSER.PARSECLOB(p, '<root><a/></root>');
-- Get the DOMDocument handle of an XML document
doc := DBMS_XMLPARSER.GETDOCUMENT(p);
-- Release parser instance
DBMS_XMLPARSER.FREEPARSER(p);
-- Retrieve a list of all elements named "root" in an XML document.
nl := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(doc, 'root');
-- Gets the first element in the list
n := DBMS_XMLDOM.ITEM(nl, 0);
-- Query node list
nl := DBMS_XMLDOM.GETCHILDNODES(n);
-- Release XML Document Resources
DBMS_XMLDOM.FREEDOCUMENT(doc);
END;
/
