Page 1 of 1
Sample program to covert XML data to cobol and vice versa.
Posted: Tue Jun 14, 2016 2:21 pm
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,
Re: Sample program to covert XML data to cobol and vice versa.
Posted: Tue Jun 14, 2016 2:43 pm
by enrico-sorichetti
google with
xml cobol ibm redbooks
and You will find lots of links to the IBM literaure discussing the subject
Re: Sample program to covert XML data to cobol and vice versa.
Posted: Tue Jun 14, 2016 3:59 pm
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?
Re: Sample program to covert XML data to cobol and vice versa.
Posted: Wed Jun 15, 2016 11:57 am
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
Re: Sample program to covert XML data to cobol and vice versa.
Posted: Fri Jun 17, 2016 1:59 pm
by Ankit Gupta
Thanks a lot Anuj.
Re: Sample program to covert XML data to cobol and vice versa.
Posted: Fri Jun 17, 2016 2:23 pm
by Anuj Dhawan
Good Luck!