Split large XML file to smaller files

Highlighted
One Star

Split large XML file to smaller files

I have an xml file which is BIG. Now I want to use Talend to split the file into x files having the same structure as the original file. For example, the orignal file contains 6 books. I want a job which creates two files, each having three books, but the structure should stay the same: sow the leading header line and the surrounding <books> tag should be in both splitted output files. For some reason I can't manage to do this within talend. Why not? I DON'T want to to configure some kind of component and build up the complete output xml myself... I just want to iterate through /books/book and save them in multiple output xml files. Why is this so hard within Talend?
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<code></code>
<text></text>
</book>
<book>
<code></code>
<text></text>
</book>
<book>
<code></code>
<text></text>
</book>
<book>
<code></code>
<text></text>
</book>
<book>
<code></code>
<text></text>
</book>
<book>
<code></code>
<text></text>
</book>
</books>
Highlighted
Employee

Re: Split large XML file to smaller files

Why is this so hard within Talend ?
it's not !
You should create your metadata XML for input and output.
then
you create a job, with a tFileInputXML and a tAvancedFileOutputXML by drag & drop metadata on designer view.
you link the 2 components together by a main link, schema sould be the same, check only java type.you can use a tConvertType too
and last step :
in the advanced setting of the tAvancedFileOutputXML you check split output and set number of rows by file
Highlighted
One Star

Re: Split large XML file to smaller files

But can I simple loop through the booms and without specifying the contents within a book, copy all the books?

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog