View previous topic :: View next topic
|
Author |
Message |
naveenkumars
New User
Joined: 17 Jun 2010 Posts: 3 Location: India
|
|
|
|
Hi,
How can I supress to print Field in XML using XML GENERATE?
Example,
Code: |
01 Books
05 Book OCCURS 2.
05 Category PIC X(10).
05 Name OCCURS 1 PIC X(10).
05 Aurthor OCCURS 1 PIC X(10).
05 Price OCCURS 1 PIC X(10).
Move 'Buy' TO Category(1).
Move 'ABC' TO Name(1 1).
Move 'XXXX' TO Aurthor(1 1).
Move 434.34 TO Price(1 1).
Move 'Free' TO Category(2).
Move 'XYZ' TO Name(2 1).
Move 'XXXX' TO Aurthor(2 1).
XML GENERATE XMLOUT FROM Books
WITH ATTRIBUTES
END-XML. |
The above code will display XML as
<Books>
<Book Category="Buy">
<Name>ABC</Name>
<Aurthor>XXXX</Aurthor>
<Price>434.34</Price>
</Book>
<Book Category="Free">
<Name>XYZ</Name>
<Aurthor>XXXX</Aurthor>
<Price> </Price>
</Book>
</Books>
I do not want to print <Price> Tag in XML for attribute 'Category=Free'.
Is there anyway to do this using XML GENERATE? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
No idea but surely the price is 0.00. By specifying a value it shows that you have not forgotten to code for price in this instance. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
I agree with Nic. However, if you are hung up on doing this, consider declaring another structure named Free-Books without the price and if price is zero, use this structure instead of the Books. |
|
Back to top |
|
|
naveenkumars
New User
Joined: 17 Jun 2010 Posts: 3 Location: India
|
|
|
|
Thank you for your replies.
In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
naveenkumars wrote: |
In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol. |
maybe that is why agkshirsagar suggested defining different structures in Working-Storage.......
which IMUHO is clever. |
|
Back to top |
|
|
|