2 Replies Latest reply: Jun 11, 2014 4:39 AM by odie_63 RSS

    XML Parsing

    2680274

      HI

       

      Sample XML File:

       

      <boHead>

      <title>123</Title>

      <head>

      <UnNo>123</unNo>

      <name>anonf</name>

      <line>

      <no>1</no>

      <qty>12</qty>

      <line>

      <no>2</no>

      <qty>40</qty>

      </line>

      </head>

      </boHead>

       

      I want to elementate all XML values and pass to PLSQL record type

       

      I am not getting, How to capture the Line level attributes?

       

      Can any one suggested parsing and assinging method

        • 1. Re: XML Parsing
          j.vkleeff

          Can you use my example?

           

          See discussion

           

          Concatenate nested XML tags

          • 2. Re: XML Parsing
            odie_63

            Basic example :

            SQL> declare

              2

              3    type my_rec is record (lno number, qty number);

              4    type my_rec_tab is table of my_rec;

              5

              6    t    my_rec_tab;

              7

              8    v_xml  xmltype := xmltype('<boHead>

              9  <title>123</title>

            10  <head>

            11  <unNo>123</unNo>

            12  <name>anonf</name>

            13  <line>

            14  <no>1</no>

            15  <qty>12</qty>

            16  </line>

            17  <line>

            18  <no>2</no>

            19  <qty>40</qty>

            20  </line>

            21  </head>

            22  </boHead>');

            23

            24  begin

            25

            26    select lno, qty

            27    bulk collect into t

            28    from xmltable('/boHead/head/line'

            29           passing v_xml

            30           columns lno  number path 'no'

            31                 , qty  number path 'qty'

            32         ) ;

            33

            34    for i in 1 .. t.count loop

            35      dbms_output.put_line(

            36        utl_lms.format_message('Line #%d : qty = %d', to_char(t(i).lno), to_char(t(i).qty))

            37      );

            38    end loop;

            39

            40  end;

            41  /

             

            Line #1 : qty = 12

            Line #2 : qty = 40

             

            PL/SQL procedure successfully completed