IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

XML Generate with Attribute & Element


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Log Thangavel

New User


Joined: 19 Jan 2018
Posts: 18
Location: USA

PostPosted: Fri Jan 19, 2018 6:21 pm
Reply with quote

Hi!

Am trying to use XML Generate to create the below format. But looks like there is no option to change as both attribute & element. Pls advise

<Master>
<Parent>
<Tag1 type=string>value1</Tag1>
</Parent>
<Parent2>Value2<Parent2>
</Master>
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jan 19, 2018 7:05 pm
Reply with quote

Is what you posted what you got or what you want? Please provide sample input and output. Also use the code tags when presenting that information.
Back to top
View user's profile Send private message
Log Thangavel

New User


Joined: 19 Jan 2018
Posts: 18
Location: USA

PostPosted: Fri Jan 19, 2018 8:18 pm
Reply with quote

Thanks for your response and Apologise for not being clear on my question.

I need to create xml format shown above. My question is

1.how we define the working storage for this structure
2.xml generate call to show both the attribute and value
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 19, 2018 8:29 pm
Reply with quote

Quote:
I need to create xml format shown above. My question is

1.how we define the working storage for this structure
2.xml generate call to show both the attribute and value
What have you tried so far? This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum so if you have not tried anything yet, how can we help you? If you have written code, let us see the code and the output (and tell us how the output does not match what you expected). Based on what I've done with XML in COBOL, I suspect that what you want to do may not be possible in COBOL.
Back to top
View user's profile Send private message
Log Thangavel

New User


Joined: 19 Jan 2018
Posts: 18
Location: USA

PostPosted: Sat Jan 20, 2018 12:00 am
Reply with quote

Code:
01 Master.
02 Parent            pic x(5) value ‘parent’
03 tag1.
05 tag-type value pic x(6) value ‘string’
02 parent2           pic x(6) value ‘parent2’
05 parent2-value  pic x(6) value ‘string’



XML generate xml-out from master
Code:
Name of parent is ‘parent’
             parent2 is ‘parent2’
Type of tag-type is attribute
            parent2-value is attribute
             parent is content
             Parent2-value is content



I was able to get the below structure

Code:
<master>
<parent type=‘string’>parent
<parent2 type=‘string’>parent2
</master>


But what is missing is the end tag for parent & parent2
Which are </parent> and </parent2>
Coded - for what it was worth (unless the code really IS that badly formed). Please use the code tags as requested so that we can see your actual code structure
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jan 20, 2018 12:43 am
Reply with quote

Which compiler are you using? Because the code you provided generates a number of syntax errors in Enterprise COBOL version 5.1.1. Furthermore, your PICTURE clauses are too small for the defined data for the Parent and parent2 variables.

Since you do not have periods ending the definition of parent or parent2, that is the most likely reason the </parent> and </parent2> were not generated. In COBOL, periods are important in some places (even though they are less important than they used to be). The problem could also be the mismatch between the variable VALUE and the PICTURE clause definition.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
No new posts JSON Generate COBOL Programming 2
No new posts UUID4 - extracting time element COBOL Programming 1
No new posts XML-GENERATE to render edited numeric COBOL Programming 0
Search our Forums:

Back to Top