• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] How to loop an element in tFileInputXML

#1 2009-09-15 17:59:51

Rashid
Guest

[resolved] How to loop an element in tFileInputXML

Tags: [loop, xml]

Hi: I am trying to map an xml document to table columns using tFileinputXML but stuck how to loop through elements that can be present more than once. E.g see the xml data below, not only I want to loop through all the elements, but I also would like to create a Many to One relationship on the basis of looped element to the relational database. Any help will be appreciated.

<entry dataset="Swiss-Prot" created="1986-07-21" modified="2009-09-01" version="151">
<accession>P00533</accession>
<accession>O00688</accession>
<accession>O00732</accession>
<accession>P06268</accession>
<accession>Q14225</accession>
<accession>Q68GS5</accession>
<accession>Q92795</accession>
<accession>Q9BZS2</accession>
<accession>Q9GZX1</accession>
<accession>Q9H2C9</accession>
<accession>Q9H3C9</accession>
<accession>Q9UMD7</accession>
<accession>Q9UMD8</accession>
<accession>Q9UMG5</accession>
<name>EGFR_HUMAN</name>
</entry>

Thanks,
Rashid.

#2 2009-09-16 04:50:09

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: [resolved] How to loop an element in tFileInputXML

Hello Rashid

Can you give us an example to expalin your request?

Best regards

          shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2009-09-16 10:03:40

Rashid
Guest

Re: [resolved] How to loop an element in tFileInputXML

Shong you can pick any example where you have one parent element tag with 1 to many child elements, some thing like the one I posted previously. Ok let me create an example and try to explain it to you. Let’s say we have a department named “Sales” with lot of employees and we want to store element department in parent table and all the sub employees in the child table.  See the xml below

<root>
<department id=1 name=”Sales”>
<employee> John </ employee >
<employee> Alex </ employee >
<employee> Sharon </ employee >
</department>
</root>

Now let’s say I have two tables Department and Employees and I want to store department "sales" on Department table and all the employees in employee table with department id 1 as the foreign key.

#4 2009-09-17 07:37:01

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: [resolved] How to loop an element in tFileInputXML

Hello
You can extract the id,name and employee from xml file, then generate two table on tMap. see my screenshots.


Best regards

         shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2009-09-17 07:40:56

Meex
Guest

Re: [resolved] How to loop an element in tFileInputXML

Hi,

I've exact the same problem, I need to import a multi level xml with nested loops?

Example:

<ZPM_EQUIPMENT_EXPORT>
  <EQUI>
    <EQUNR>000000000010032036</EQUNR>
    <AEDAT>2009-07-07</AEDAT>
  </EQUI>
  <CLOBJDAT>
    <CLOBJDAT>
      <TABIX>1</TABIX>
      <ATFLV>9.9E1</ATFLV>
      <ATNAM>ZZ_IT_KOSTENGRUPPE</ATNAM>
    </CLOBJDAT>
    <CLOBJDAT>
      <TABIX>2</TABIX>
      <ATFLV>0</ATFLV>
      <ATNAM>ZZ_ANLAGENHAUPTNUMMER</ATNAM>
    </CLOBJDAT>
  <CLOBJDAT>
</ZPM_EQUIPMENT_EXPORT>

regards
Meex

#6 2009-09-17 09:55:43

Rashid
Guest

Re: [resolved] How to loop an element in tFileInputXML

Thanks Shong that was exactly I was looking for.

Regards,
RJ.

#7 2009-09-17 14:22:53

Meex
Guest

Re: [resolved] How to loop an element in tFileInputXML

but this doesn't work for my case!

#8 2009-09-17 16:21:46

Meex
Guest

Re: [resolved] How to loop an element in tFileInputXML

ok, found the solution: http://www.talendforge.org/forum/viewtopic.php?id=6016

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] How to loop an element in tFileInputXML

Board footer

Powered by FluxBB