I am trying to parse a huge XML CLOB data to get some node values. So I wrote a method with the help of DBMS_XMLPARSER to retrieve a value of a node and it works fine.
FUNCTION Get_Node_Value(
node_ IN DBMS_XMLDOM.DOMNode) RETURN VARCHAR2
IS
sub_nodes_list_ DBMS_XMLDOM.DOMNodeList;
sub_nodes_len_ NUMBER;
value_node_ DBMS_XMLDOM.DOMNode;
value_ VARCHAR2(50);
BEGIN
sub_nodes_list_ := DBMS_XMLDOM.Getchildnodes(node_);
sub_nodes_len_ := DBMS_XMLDOM.GetLength(sub_nodes_list_); -- sub_nodes_len_ should be 1
IF ( sub_nodes_len_ > 0 ) THEN
value_node_ := DBMS_XMLDOM.Item(sub_nodes_list_, 0);
value_ := DBMS_XMLDOM.GetNodeValue(value_node_);
END IF;
RETURN value_;
END Get_Node_Value;
But I am wondering to have a common method where I give XML CLOB and node name as parameters and get node value return back or something relevant. Since the XML is too large, using such a method will cut down unnecessary coding. Any help will be appreciated!