View previous topic :: View next topic
|
Author |
Message |
Log Thangavel
New User
Joined: 19 Jan 2018 Posts: 18 Location: USA
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Log Thangavel
New User
Joined: 19 Jan 2018 Posts: 18 Location: USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Log Thangavel
New User
Joined: 19 Jan 2018 Posts: 18 Location: USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|