Sample program to covert XML data to cobol and vice versa.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Ankit Gupta
Registered Member
Posts: 24
Joined: Fri Aug 16, 2013 1:30 pm

Sample program to covert XML data to cobol and vice versa.

Post by Ankit Gupta »

Hi
Is there a step by step example of some example program in which it is shown to change/convert the cobol data into XML format and covert XML data back to cobol. It'd be nice if you can direct me to some sample program? Thanks,
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 825
Joined: Wed Sep 11, 2013 3:57 pm

Re: Sample program to covert XML data to cobol and vice versa.

Post by enrico-sorichetti »

google with
xml cobol ibm redbooks
and You will find lots of links to the IBM literaure discussing the subject
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Sample program to covert XML data to cobol and vice versa.

Post by nicc »

covert XML data back to cobol.
What, exactly, do you mean by 'cobol'? Have you coded your COBOL program code as XMLfor some reason and want to convert it back again?
Regards
Nic
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Sample program to covert XML data to cobol and vice versa.

Post by Anuj Dhawan »

Start from these, may be:

Code: Select all

Identification division.                                                 
 Program-id. PARSESEG.                                                    
 Environment division.                                                    
 Input-output section.                                                    
 File-control.                                                            
     Select Input-XML                                                     
      Assign to infile                                                   
      File status is Input-XML-status.                                   
 Data division.                                                           
 File section.                                                            
 FD Input-XML                                                             
     Record is varying from 1 to 255 depending on Rec-length              
     Recording mode V.                                                    
 1 fdrec.                                                                 
   2 pic X occurs 1 to 255 depending on Rec-length .                      
 Working-storage section.                                                 
 1 Event-number comp pic 99.                                              
 1 Rec-length comp-5 pic 9(4).                                            
 1 Input-XML-status pic 99.                                               
 Procedure division.                                                      
     Open input Input-XML                                                 
     If Input-XML-status not = 0                                          
       Display 'Open failed, file status: '  Input-XML-status             
       Goback                                                             
     End-if                                                               
     Read Input-XML                                                       
     If Input-XML-status not = 0                                          
       Display 'Read failed, file status: '  Input-XML-status             
       Goback                                                             
     End-if                                                               
     Move 0 to Event-number                                               
     Display 'Starting with: ' fdrec                                     
     Display 'Event number and name    Content of XML-text'               
     XML parse fdrec processing procedure Handle-parse-events             
     Close Input-XML                                                      
     Goback                                                               
     .                                                                    
 Handle-parse-events.                                                     
     Add 1 to Event-number                                                
     Display '  ' Event-number ': ' XML-event '{' XML-text '}'            
     Evaluate XML-event                                                   
       When 'END-OF-INPUT'                                                
         Read Input-XML                                                   
         Evaluate Input-XML-status                                        
           When 0                                                         
             Move 1 to XML-code                                           
             Display 'Continuing with: ' fdrec                            
           When 10                                                        
             Display 'At EOF; no more input.'                             
           When other                                                     
             Display 'Read failed, file status:' Input-XML-status         
             Goback                                                       
         End-evaluate                                                     
       When other                                                         
         Continue                                                         
     End-evaluate                                                         
          .                                                                    
 End program PARSESEG.                                                    

Result:

Code: Select all

Starting with:   <?xml version='1.0'?> 
Event number and name      Content of {XML-TEXT} 
 01: START-OF-DOCUMENT      {} 
 02: VERSION-INFORMATION    {1.0} 
 03: END-OF-INPUT           {} 
Continuing with:    <Tagline> 
 04: START-OF-ELEMENT       {Tagline} 
 05: END-OF-INPUT           {} 
Continuing with:    COBOL is the language of the future! 
 06: CONTENT-CHARACTERS     {COBOL is the language of the future!} 
 07: END-OF-INPUT           {} 
Continuing with:    </Tagline> 
 08: CONTENT-CHARACTERS     {} 
 09: END-OF-ELEMENT         {Tagline} 
 10: END-OF-DOCUMENT        {}
http://www.ibm.com/support/knowledgecen ... xml21e.htm
http://www.canamsoftware.com/Portals/3/ ... 0COBOL.pdf
http://www-01.ibm.com/support/docview.w ... 4198&aid=1
http://publibz.boulder.ibm.com/cgi-bin/ ... 3836&CASE=
http://publibz.boulder.ibm.com/cgi-bin/ ... 0923143836
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Ankit Gupta
Registered Member
Posts: 24
Joined: Fri Aug 16, 2013 1:30 pm

Re: Sample program to covert XML data to cobol and vice versa.

Post by Ankit Gupta »

Thanks a lot Anuj.
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Sample program to covert XML data to cobol and vice versa.

Post by Anuj Dhawan »

Good Luck!
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”