Skip to content

Instantly share code, notes, and snippets.

@moose56
Last active March 18, 2018 15:01
Show Gist options
  • Save moose56/f5d0a6c75cd9aad3477fd4f912ae6983 to your computer and use it in GitHub Desktop.
Save moose56/f5d0a6c75cd9aad3477fd4f912ae6983 to your computer and use it in GitHub Desktop.
----------------------------------------------------------------------------
FUNCTION fw_xml_add_child(p_parent IN XMLTYPE, p_child IN XMLTYPE)
----------------------------------------------------------------------------
RETURN XMLTYPE
AS
l_parent_dom DBMS_XMLDOM.DOMDocument;
l_parent_elem DBMS_XMLDOM.DOMElement;
l_child_dom DBMS_XMLDOM.DOMDocument;
l_child_elem DBMS_XMLDOM.DOMElement;
l_child_node DBMS_XMLDOM.DOMNode;
l_import_node DBMS_XMLDOM.DOMNode;
l_result_node DBMS_XMLDOM.DOMNODE;
l_return XMLTYPE;
BEGIN
l_parent_dom := DBMS_XMLDOM.NEWDOMDOCUMENT(p_parent);
l_parent_elem := DBMS_XMLDOM.GETDOCUMENTELEMENT(l_parent_dom);
l_child_dom := DBMS_XMLDOM.NEWDOMDOCUMENT(p_child);
l_child_elem := DBMS_XMLDOM.GETDOCUMENTELEMENT(l_child_dom);
l_child_node := DBMS_XMLDOM.MAKENODE(l_child_elem);
l_import_node := DBMS_XMLDOM.IMPORTNODE(l_parent_dom, l_child_node, TRUE);
l_result_node := DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(l_parent_elem), l_import_node);
l_return := DBMS_XMLDOM.GETXMLTYPE(l_parent_dom);
DBMS_XMLDOM.FREEDOCUMENT(l_parent_dom);
DBMS_XMLDOM.FREEDOCUMENT(l_child_dom);
RETURN l_return;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment