Oracle 10g: Extract data (select) from XML (CLOB Type)

前端 未结 7 810
悲哀的现实
悲哀的现实 2021-02-07 20:05

I\'m new in Oracle and I\'ve - maybe trivial - a problem in a select. (I\'m using Oracle 10g Express Edition).

I\'ve a DB with a field CLOB: mytab.xml This column have a

7条回答
  •  清酒与你
    2021-02-07 20:31

    You can try creating DBMS_XMLPARSER.parser object from the CLOB XML and get a DBMS_XMLDOM.DOMDocument object from it. Then use DBMS_XMLDOM package methods to get the value of any node.

       xml_            CLOB := 'X';
       p               DBMS_XMLPARSER.parser;
       doc_            DBMS_XMLDOM.DOMDocument;
    
          -- Convert the CLOB into a XML-document
          P := DBMS_XMLPARSER.newparser();
          -- Parse the clob and get the XML-document
          DBMS_XMLPARSER.parseclob(p, xml_);
          doc_ := DBMS_XMLPARSER.getDocument(p);
    

    Then use the below methods to extract node value

    DBMS_XMLDOM.getElementsByTagName(doc_, 'NodeName'); DBMS_XMLDOM.GetNodeValue(node_obj_);

    Refer more about DBMS_XMLDOM methods here.

提交回复
热议问题