[resolved] How to loop an element in tFileInputXML

One Star

[resolved] How to loop an element in tFileInputXML

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.

Accepted Solutions
One Star

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


All Replies
Community Manager

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

Hello Rashid
Can you give us an example to expalin your request?
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

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.
Community Manager

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

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
One Star

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

Thanks Shong that was exactly I was looking for.
Regards,
RJ.
One Star

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

but this doesn't work for my case!
One Star

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

One Star

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

I tried that, and I still get multiple records for department. I only want one entry for department. Please help.
Community Manager

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

I tried that, and I still get multiple records for department. I only want one entry for department. Please help.

Please report a new topic for your problem with details, so that we can know clear what's the problem you really meet and assist you further.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

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

Hi Shong,
My input xml file as follows. And I have given absolute Xpath : /model-response-list/model-responses/model/attribute but I am getting all attribute information in single colum. Could you please help us and I am unable to see your old screen prints.
<model-response-list xmlns="" throttle="1000" total-models="33328">
<model-responses>
<model mh="0x65a000">
<attribute id="0x1006e">alpcissapp922c</attribute>
<attribute id="0x10030"/>
<attribute id="0x23000e">IP Device</attribute>
<attribute id="0x12d7f">3.34.235.67</attribute>
<attribute id="0x10023" error="NoSuchAttribute"/>
<attribute id="0x10032"/>
</model>
</model-responses>
</model-response-list>
One Star

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

How to display my root Element using tFileInputMSXML
One Star

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

I want to read this XML file using tFileInputMSXML  as two Schemas as 1- Header(/AllianceInventory6/Invoice/(Vendor,InvoiceNumber,InvoiceDate..)) and Data(/AllianceInventory6/Invoice/ProductListing/Product/@(UPC,QuantityAdjusted..))
but it is hard to insert for X-path loop for both the schema as the Second Schema is within Invoice.Please help me how to read the file using tFileInputMSXML.