ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

XML Parsing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML Parsing

    Hi,

    We need to process a transaction file which is sent in XML format. The file will contain a Transaction batch and within batch there would be transaction detail records. In a day we will get many transaction batches and each batch will contain lot of transaction details.

    Since the no of batches and no of transactions with each batch are huge I cannot declare a qualified DS to hold so many transactions as the size limitation was 64K. I have looked into some articles talking about callback processing.

    I have tried using the concept of callback processing by declaring the DS as shown below but the parsing was not totally successful.

    Code:
    DACIHandler       PR            10I 0                                
    D BatchCount                     5I 0                                
    D TransBatch                            LikeDs(TransBatchDS) Dim(1) Const
    D numRecs                       10I 0 Value                          
    D                                                                    
    D BatchCount      S              5I 0                                
    D OPTIONS         S            256A   Varying                        
    D*                                                                   
    DTransBatchDS       DS                  Qualified                      
    DBatchNo                         7a                                  
    DStartDate                      14a                                  
    DEndDate                        14a                                  
    DOriginal                        6a                                  
    DRecordCount                    10  0                                
    DTransRecord...                                                        
    D                                     LikeDS(StlTrans) dim(1)        
    DStlTrans         Ds                  Qualified                      
    D RRNo                          25a                                  
    D MID                           15a                                  
    D TxnNo                          6  0  
    D PAN                           30  0  
    D*                                     
      /free
    
          Options = 'case=any doc=file +                
                    path= TransHeader/TransBatch +        
                    allowmissing=yes allowextra=yes';  
                                                       
           XML-INTO %HANDLER(TransHandler : BatchCount)    
                  %XML(%Trim(xmlpath):Options);        
    
      /end-free
    Can someone tell me how to parse the xml file using callback processing or should I have to go with XML-SAX?

    I have attached the sample data in xml format.

    Thanks a lot.

    Thanks,
    Rahul
    Attached Files

  • #2
    Re: XML Parsing

    Hi,

    Check out this link...



    Hope this will be usefull.

    Thanks
    Hsp
    'Coding = Experience'
    hsp

    Comment

    Working...
    X