in reply to splitting large xml documents

What you need is an XML parser to create a structure from your original file, which you can then modify and output as multiple XML files. XML::Simple or XML::Parser will probably do the trick.

Replies are listed 'Best First'.
Re^2: splitting large xml documents
by inman (Curate) on Sep 06, 2005 at 09:16 UTC
    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.
      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.