Re: XML Parsing Question

From: ExecMan <artmerar_at_yahoo.com>
Date: Tue, 1 May 2012 07:46:19 -0700 (PDT)
Message-ID: <3b5f7b95-325c-4a6d-a1f7-1224fd0c9684_at_s7g2000yqm.googlegroups.com>



On May 1, 9:06 am, dombrooks <dombro..._at_hotmail.com> wrote:
> Yes / It depends.
>
> The above is just a demo using with/your_xml to simulate the source of a valid doc/snippet of xml.

Well, being new at this XML thingy I'm not sure I am getting the code. Here is what I currently have in place. This works fine, except now we are getting multiple of the TICKER node, and I need to loop and process those.

  v_xml_id := OPEN_FILES(p_xml_dir,p_xml_files,'r');

  LOOP
    BEGIN
      UTL_FILE.GET_LINE(v_xml_id,v_xml_file);

      v_parser := xmlparser.newParser;
      dbms_xmlparser.setBaseDir(v_parser,p_xml_dir);
      xmlparser.parse(v_parser,v_xml_file);
      v_doc := xmlparser.getDocument(v_parser);
      xmlparser.freeParser(v_parser);

      v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/
ETF_Report');
  • Loop through the document and create a new record in table collection FOR v_rec IN 0 .. dbms_xmldom.getLength(v_nl) - 1 LOOP BEGIN v_n := dbms_xmldom.item(v_nl, v_rec);
          v_etf_tab.EXTEND;
          v_etf_tab(v_etf_tab.LAST).title  :=
xslprocessor.valueOf(v_n,'/ETF_Report/Title');
          v_etf_tab(v_etf_tab.LAST).ticker :=
xslprocessor.valueOf(v_n,'/ETF_Report/Tickers/Ticker');

          DBMS_OUTPUT.PUT_LINE('HERE: ' || v_etf_tab(v_etf_tab.LAST).title);

          DBMS_OUTPUT.PUT_LINE('HERE: ' || v_etf_tab(v_etf_tab.LAST).ticker);

          EXCEPTION
          WHEN OTHERS THEN
             NULL;
        END;
      END LOOP;

      EXCEPTION
      WHEN NO_DATA_FOUND THEN
        UTL_FILE.FCLOSE_ALL;
        EXIT;

    END;     xmldom.freeDocument(v_doc);
  END LOOP; Received on Tue May 01 2012 - 09:46:19 CDT

Original text of this message