in reply to Re: splitting large xml documents
in thread splitting large xml documents

Both of these modules read the XML structure into memory. If the files are 'large' then this might be a problem. XML::Twig will handle this better.

Replies are listed 'Best First'.
Re^3: splitting large xml documents
by Anonymous Monk on Sep 06, 2005 at 10:05 UTC
    Am I on the write track with this? It seems to work ok.

    Many thanks...

    my $t = XML::Twig->new(); $t->parsefile( $Globals::input_xml_dir."TimesheetLoad_1.xml" ); my $rt = $t->root; # NikuDataBus my $hd = $rt->first_child( 'Header' ); my $tp = $rt->first_child( 'Customers' ); $tp->cut; my @tp1 = $tp->children( 'Customer' ); my $count = 0; foreach my $tp1 (@tp1) { $tp1->cut; $tp1->paste( after => $hd, $rt ); my $out; open ($out, ">$Globals::input_xml_dir\\twigs\\CustomerLoad_$cou +nt.xml"); $rt->print( $out ); close $out; $tp1->cut; $count++; }
      Doh!

      It misses out the Customers element.