Thank you very much haukex!

The API of XML::Writer appeared to be a bit too complex for me at first. However I tried it just now - and indeed it seems to write the output continually (which I checked with the commented "Hi" line below. The syntax was not very verbose either on the second look :-) A bit strange (to my taste) is the option NEWLINES which adds a newline before the closing delimiter, however it does make the output human readable.

I will test the module with my real data. Many thanks again!

#!/perl use strict; use warnings FATAL => qw(all); use Text::CSV_XS; use XML::Writer; my $csv_par = { binary => 1, auto_diag => 1, allow_whitespace => 1, sep_char => ';', eol => $/, quote_char => undef, }; my $csv = Text::CSV_XS->new($csv_par); my @header = @{$csv->getline(*DATA)}; my %rec; $csv->bind_columns(\@rec{@header}); my $writer = XML::Writer->new(NEWLINES => 1, ENCODING => 'UTF-8'); # stdout. $writer->xmlDecl(); # ("UTF-8") already mentioned above. $writer->startTag('ROOT'); while ( $csv->getline(*DATA) ) { $writer->startTag('alpha', 'name' => $rec{"alpha"}); for my $other( qw(beta gamma) ) { $writer->startTag($other, 'name' => $rec{$other}); $writer->endTag($other); } # print "\t\tHi!\n"; $writer->endTag('alpha'); } $writer->endTag('ROOT'); $writer->end(); __DATA__ alpha;beta;gamma q;2;3 w;9;8 e;1;2 r;6;7 t;5;9 y;3;1

In reply to Re^2: Creating a xml file in chunks by vagabonding electron
in thread Creating a xml file in chunks by vagabonding electron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.