midrange.com code scratchpad
Name:
Alan Cassidy
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
05/20/2014 04:41:18 pm
IP:
Logged
Description:
This is for the discussion on using XML-INTO for parsing an XML-XLSX file, subject line:
RE: Parsing an XML-XLSX file using XML-INTO
Code:
  1.  
  2.      H   OPTION( *SRCSTMT )
  3.       * =====================================================================
  4.      D PSDS           SDS
  5.      D RowCount                      10i 0 overlay( PSDS : 372 )
  6.       * ----------------------------------------------------
  7.       *  Data structures for Handler parameters and processing
  8.      D Row             ds                  Qualified  Dim( 100 )
  9.      D  Cell                               likeds( Cell_T )   dim( 30 )
  10.      D  CountCell                     5i 0
  11.      D p_row           s               *
  12.       * ------------------                 -----------------
  13.      D Cell_T          ds                   Dim( 26 ) Qualified
  14.      D  data                                LikeDS( Data_T )
  15.       * ------------------                 -----------------
  16.      D Data_T          DS                  Template
  17.      D  Type                         20a
  18.      D  Data                         50a
  19.       * ------------------                 -----------------
  20.  
  21.       * --------------------------------------------------------------------
  22.      D XPARSE          pr                  ExtPgm( 'XPARSE' )
  23.      D  p_fpath                     640a
  24.       * ---------------------------------------------------
  25.      D xParse          pi
  26.      D  filepath                    640a
  27.       * ---------------------------------------------------
  28.      D fpath           s            640a   based( pfpath )
  29.      D rtncode         s             10i 0
  30.      D options         s            128a
  31.      D xc              s             10i 0
  32.      D xr              s             10i 0
  33.       *
  34.       /free
  35.        *inlr = *on ;
  36.        //
  37.        pfpath = %addr( filepath ) ;
  38.        %str( pfpath: %size(fpath)) = %trim( filepath ) ;
  39.        //
  40.        /// options   = 'countpfx=Count  +
  41.        options =   'path=Workbook/Worksheet/Table/Row  +
  42.                     doc=file  +
  43.                     datasubf=Data  +
  44.                     ns=remove  +
  45.                     case=any  +
  46.                     trim=all  +
  47.                     allowextra=yes  +
  48.                     ' ;
  49.        xml-into   row   %XML( %str(pfpath) : options );
  50.        //
  51.        dsply ('Processed ' + %char( RowCount ) + ' Rows' ) ;
  52.        //
  53.        for xr = 1 to RowCount ;
  54.          for xc = 1 to Row(xr).CountCell ;
  55.            dsply  ('Row ' + %char(xr) + ' Cell ' + %char(xc)
  56.                                       + ' Data=' ) ;
  57.            dsply  ( Row(xr).Cell(xc).Data.Data ) ;
  58.          endfor ;
  59.        endfor ;
  60.        //
  61.  
  62.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css