Extracting multiple occurences in XML file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Extracting multiple occurences in XML file

Post by cosec »

I have an xml file with repeated info such as the following.

example:

<PRODUCT_INFO>
<PROD_CD>PROD_CD1</PROD_CD>
<PRODUCT_INFO>
<PRODUCT_INFO>
<PROD_CD>PROD_CD2</PROD_CD>
<PRODUCT_INFO>

I am required to store the first occurence (i.e. PROD_CD1) under a Field A and the second occurence (i.e. PROD_CD2) under a Field B.

I am able to extract the value for the first occurence. However unable to retrieve the second occurence. Please advice. Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Set up a stage variable to report whether you've already seen the opening PROD_CD tag - if you have, transfer the value to the second field; if you haven't, transfer the value to the first field.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

One question:
Any idea why the 'product_info' tag is not 'ending' ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Probably because cosec forgot to type the / characters!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply