This morning I'm going for an easy one.
l_doc := DBMS_XMLDOM.newDomDocument(cl => l_clob);
l_rootElem := DBMS_XMLDOM.getDocumentElement(doc => l_doc);
l_rootNode := DBMS_XMLDOM.makeNode(elem => l_rootElem); -- this is line 436
ORA-31181: PL/SQL DOM handle accesses node that is no longer available
ORA-06512: at "XDB.DBMS_XMLDOM", line 2554
ORA-06512: at "XDB.DBMS_XMLDOM", line 2572
ORA-06512: at "TAMEME.TAMEME", line 436
ORA-06512: at line 6
This error is easily explained: you cannot free the object containing the DOM document until you have finished processing all the objects derived from it.
In the code snippet above, procedure DBMS_XMLDOM.freeDocument must be moved after DBMS_XMLDOM.freeNode.
In other words, the call to DBMS_XMLDOM.makeNode is out of scope.
See message translations for ORA-31181 and search additional resources.