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>
2 REPLIES
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
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?