ITEM v18
The ITEM function returns the item in the collection corresponding to the idx parameter. If the value of the idx parameter is greater than or equal to the number of nodes in the list, then the function returns NULL.
ITEM(nl DOMNodeList, idx IN PLS_INTEGER) RETURN DOMNode
Parameters
nl
The DOMNodeList, that is, the number of nodes in the list.
idx
The index in the NODELIST that's used to retrieve the item.
Examples
This example uses a function func1 that creates an XML structure <Departments>Dept1</Departments> and returns the document node that's the root node:
CREATE OR REPLACE FUNCTION func1 RETURN DBMS_XMLDOM.DOMNode IS l_domdoc DBMS_XMLDOM.DOMDocument; l_root_node DBMS_XMLDOM.DOMNode; l_department_element DBMS_XMLDOM.DOMElement; l_departments_node DBMS_XMLDOM.DOMNode; l_name_text DBMS_XMLDOM.DOMText; l_name_textnode DBMS_XMLDOM.DOMNode; BEGIN l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT; l_root_node := DBMS_XMLDOM.MAKENODE(l_domdoc); l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' ); l_departments_node := DBMS_XMLDOM.APPENDCHILD(l_root_node,DBMS_XMLDOM.MAKENODE(l_department_element)); l_name_text := DBMS_XMLDOM.CREATETEXTNODE(l_domdoc, 'Dept1' ); PERFORM DBMS_XMLDOM.APPENDCHILD(l_departments_node,DBMS_XMLDOM.MAKENODE(l_name_text)); return l_root_node; END;
The document node is passed to GETCHILDNODES using the function func1, which returns the list of children of the document node. The list contains the DOMElement representing Departments. The call to the item returns this element as a DOMNode, which is then picked by GETNODENAME to fetch the tag name of this DOMElement.
DECLARE clist DBMS_XMLDOM.DOMNodeList; l_node DBMS_XMLDOM.DOMNode; BEGIN clist := DBMS_XMLDOM.GETCHILDNODES(func1()); l_node := DBMS_XMLDOM.ITEM(clist, 0); dbms_output.put_line(DBMS_XMLDOM.GETNODENAME(l_node)); END;
- On this page
- Parameters
- Examples