The ITEM function returns the DBMS_XMLDOM.DOMNODE handle of the idx-th node (counting from 0) in a node list.
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.item (
nodelist IN DBMS_XMLDOM.DOMNODELIST,
idx IN NUMBER);
Parameters
Parameter |
Description |
|---|---|
| nodelist | The DBMS_XMLDOM.DOMNODELIST handle of the node list. |
| idx | Node index, starting from 0. |
Return value
The DBMS_XMLDOM.DOMNODE handle at index idx in the list.
Usage instructions
It is generally recommended to use it in conjunction with GETLENGTH. Before accessing the index, you should first check whether the idx is within the valid range [0, GETLENGTH(nodelist) - 1] to avoid out-of-bounds errors. If the index is invalid, the specific behavior may vary by implementation: it might return null or throw an exception.
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 first two nodes from the list:
-- Declare parser and document handle variables
DECLARE
p DBMS_XMLPARSER.PARSER;
doc DBMS_XMLDOM.DOMDOCUMENT;
nl DBMS_XMLDOM.DOMNODELIST;
n DBMS_XMLDOM.DOMNODE;
BEGIN
-- Create a parser instance
p := DBMS_XMLPARSER.NEWPARSER;
-- Parse the XML document in the parser.
DBMS_XMLPARSER.PARSECLOB(p, '<root><a/><b/></root>');
-- Get the DOMDocument handle of an XML document
doc := DBMS_XMLPARSER.GETDOCUMENT(p);
-- Release parser instance
DBMS_XMLPARSER.FREEPARSER(p);
-- Get list of all elements in an XML document
nl := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(doc, '*');
-- Get the first node in the list
n := DBMS_XMLDOM.ITEM(nl, 0);
-- Gets the second node in the list.
n := DBMS_XMLDOM.ITEM(nl, 1);
-- Release XML Document Resources
DBMS_XMLDOM.FREEDOCUMENT(doc);
END;
/
