MAKEELEMENT v18
The MAKEELEMENT function converts a specified DOMNode into a DOMElement and returns it.
MAKEELEMENT can convert only a DOMNode that originates from a DOMElement. If the DOMNode originates from a different type, like a DOMText, MAKEELEMENT fails.
MAKEELEMENT(n DOMNode) RETURN DOMElement
Parameters
n
Value of the DOMNode to convert.
Examples
This example defines a namespace example and uses an XMLType string to create an XML structure. GETFIRSTCHILD then returns a DOMNode that represents a DOMElement. Since GETATTRIBUTE expects a DOMElement, the MAKEELEMENT function converts a specified DOMNode into a DOMElement and returns it.
DECLARE l_domdoc DBMS_XMLDOM.DOMDocument; l_departments_node DBMS_XMLDOM.DOMNode; item_node DBMS_XMLDOM.DOMNode; BEGIN l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT(XMLTYPE('<b:collection xmlns:b="example:namespace"><b:item b:type="primary" b:id="janedoe@example.com"></b:item></b:collection>')); l_departments_node := DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.MAKENODE(l_domdoc)); item_node := DBMS_XMLDOM.GETFIRSTCHILD(l_departments_node); dbms_output.put_line('item node: ' || DBMS_XMLDOM.GETNODENAME(item_node)); dbms_output.put_line('item attr: ' || DBMS_XMLDOM.GETATTRIBUTE(DBMS_XMLDOM.MAKEELEMENT(item_node), 'id', 'example:namespace')); DBMS_XMLDOM.FREEDOCUMENT(l_domdoc); END;
- On this page
- Parameters
- Examples