Parse Repeating XML Tags

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
naveend
Participant
Posts: 11
Joined: Mon May 12, 2008 12:49 pm

Parse Repeating XML Tags

Post by naveend »

I am getting input XML in the format below. I need to pull the value in the tag <name> and create 1 row with 7 columns (populated by the different values in the <name> tag). Since the tag name <EObjCdProdTp> is the same for all the blocks, I am getting 7 rows and 1 column. Is there a way to do this?


<ResponseObject>
<EObjCdProdTp>
<description>SEM</description>
<lang_tp_cd>100</lang_tp_cd>
<lang_type>English</lang_type>
<last_update_dt>2008-05-20 12:00:00.0</last_update_dt>
<name>616</name>
<tp_cd>6000673</tp_cd>
</EObjCdProdTp>
<EObjCdProdTp>
<description>COMPACT</description>
<lang_tp_cd>100</lang_tp_cd>
<lang_type>English</lang_type>
<last_update_dt>2008-05-20 12:00:00.0</last_update_dt>
<name>MMCWL</name>
<tp_cd>5001035</tp_cd>
</EObjCdProdTp>
<EObjCdProdTp>
<description>Compact Wheel</description>
<lang_tp_cd>100</lang_tp_cd>
<lang_type>English</lang_type>
<last_update_dt>2008-05-20 12:00:00.0</last_update_dt>
<name>CWL</name>
<tp_cd>4001020</tp_cd>
</EObjCdProdTp>
<EObjCdProdTp>
<description>Compact Equip</description>
<lang_tp_cd>100</lang_tp_cd>
<lang_type>English</lang_type>
<last_update_dt>2008-05-20 12:00:00.0</last_update_dt>
<name>CCE</name>
<tp_cd>3001003</tp_cd>
</EObjCdProdTp>

</ResponseObject>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

It is what it is, seven "instances" of a thing called EObj... You need a technique to "reverse pivot" your seven rows. I'm sure there are many such techniques described in the forum here (it can be done in a variety of ways that use everything from stage variables to Aggregations), along with one or two entries that describe using XSLT, if you want to go that route.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
shukla_krishna
Premium Member
Premium Member
Posts: 28
Joined: Mon Apr 20, 2009 11:27 pm
Location: san antonio

Post by shukla_krishna »

eostic wrote:It is what it is, seven "instances" of a thing called EObj... You need a technique to "reverse pivot" your seven rows. I'm sure there are many such techniques described in the forum here (it can be done in a variety of ways that use everything from stage variables to Aggregations), along with one or two entries that describe using XSLT, if you want to go that route.

Ernie
Parse the fisrt object and take the resultant in a column , and aply xml inut stage , with ur defined table structure . u will get 7 rows based on ur table structure
Krishna Shukla
Post Reply