Page 1 of 1

How to read a Payload xml

Posted: Mon Aug 23, 2010 1:12 am
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

Posted: Mon Aug 23, 2010 1:26 am
by Sreenivasulu
As long as its a valid XML datastage would be able to read it.
Use External source + XML Input stage

Regards
Sreeni

Posted: Mon Aug 23, 2010 1:31 am
by major
Hi Sreeni,

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

Thanks

Posted: Mon Aug 23, 2010 6:08 am
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?

Posted: Mon Aug 23, 2010 8:39 am
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...

Posted: Tue Sep 07, 2010 5:07 am
by major
Thanks guys,

thanks Arun for your example