How to read a Payload xml

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
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

How to read a Payload xml

Post by major »

Hi,

I have a Payload file which will come as a .xml file and the contents of it will be as below

Code: Select all

- <ns0:PamMBLotData xmlns:ns0="http://AIG.GIG.DART.Common.MultiBasisLOTSchema.PamMBLotData">
  <Item ShortName="James" LongName="James Andy" Number="123456" Code="444" /> 
  </ns0:PamMBLotData>
For sample I have put only 4 columns but my original xml contains around 100 columns.

Now what i have to do is to read the above xml and write it to a flat file in 4 columns
For eg: James to column 1
James Andy to column 2
123456 to column 3
444 to column 4

The above is not in xml format which DataStage can read using xml stages

Could anyone please suggest some solution for this

Thanks in advance
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

As long as its a valid XML datastage would be able to read it.
Use External source + XML Input stage

Regards
Sreeni
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

Hi Sreeni,

But i need to distinguish the columns , how can i do that

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You just need to have valid 'XPath Expressions' in the XML Input stage so it can parse them out properly and it's perfectly OK to only define a small number of columns and ignore the rest. Do you have an xsd for this? That would be the best metadata import source (which is what builds the XPath Expressions for you) but worst case you can point it at the xml file as well.

Have you done that? Imported any kind of metadata for the file and loaded it into the XML Input stage? Worked with XML via DataStage before?
-craig

"You can never have too many knives" -- Logan Nine Fingers
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

From What I know, these are called attributes.

For example,

Say below is your XML:

<Root>
<Item ShortName="James" LongName="James Andy" Number="123456" Code="444"> ABCD </Item>
</Root>

To read the value of the Item tag your XPath should be

Code: Select all

 /Root/Item/text()
And to read the attributes, your XPath should be

Code: Select all

 /Root/Item/@ShortName 
And So on...
Arun
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

Thanks guys,

thanks Arun for your example
Post Reply