Need help while reading xml file

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
moulipx
Participant
Posts: 22
Joined: Tue Mar 09, 2010 8:13 am

Need help while reading xml file

Post by moulipx »

Hi all,

Could you please help me in reading below XML file .I need to produce an sequential file from Xml input file .

<Employee Place="USA" Status="Active" Date="2012-09-30">
<Name="AAA" No="1" Grade="B" />
<Name="BBB" No="2" Grade="D" />
<Name="CCC" No="3" Grade="F" />
</Employee>


I need to Create output file as below format

Name,No,Grade
AAA,1,B
BBB,2,D
CCC,3,F
Chandra Mouli
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What kind of help do you need? What have you tried and what issues have you faced? Have you ever worked with XML before?
-craig

"You can never have too many knives" -- Logan Nine Fingers
moulipx
Participant
Posts: 22
Joined: Tue Mar 09, 2010 8:13 am

Post by moulipx »

Hi ,
I never worked on XML part earlier. So please help me in extracting mentioned XML file
Chandra Mouli
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

Online-help contains a Section InfoSphere DataStage and QualityStage --> Reference -->XML-transformation containing a tutorial for the XML-Stage contained in IBM Information Server from version 8.5 FP1.
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

What everyone is saying here is to just follow the doc and give it a shot...the xml above is actually very straightforward and an excellent one to start with when learning about the various xml stages. Hint --- you'll need a table definition, and for this, the xmlInput Stage will be fine..... and spend more time doing searches thru the forum here. There are many threads that discuss xml, how to read it from disk, what to specify in the Stages, etc.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I take that back. Sorry --- the xml that you have pasted up above is not legitimate xml. There needs to be an element name collecting the various attributes for each "name" line.

Did you cut and paste this from somwhere or type it in manually?

<Employee Place="USA" Status="Active" Date="2012-09-30">
<Name="AAA" No="1" Grade="B" />
<Name="BBB" No="2" Grade="D" />
<Name="CCC" No="3" Grade="F" />
</Employee>

Look carefully at the source again. It "should" be easy, but not in this format.

A good tricks to always try:

...put a string like that in an editor, like Notepad and add an xml header line at the top....

<?xml version="1.0" ?>

...then try to open it in IE or other favorite browser. You'll see that this one dies. It is not well-formed.

The problem is the attribute lines...the probably should be something like:

<EmployeeDetail Name="AAA" No="1" Grade="B" />

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply