Hi, I tried like this by using XML::LibXML::Reader

#!/usr/bin/perl use warnings; use strict; use Carp; use File::Find; use File::Spec::Functions qw( canonpath ); use XML::LibXML::Reader; use Data::Dumper; my $INFO; my @ARGV ="C:/file/dir"; die "Need directories\n" unless @ARGV; find( sub { my $file = $_; #my $path = canonpath $File::Find::name; my $path =$_; return unless -f $path; return unless $file =~ /[.]xml\z/i; extract_information($path); return; }, @ARGV ); sub extract_information { my( $path)=@_; my $ret = open my $xmlin, '<', $path; unless ($ret) { carp "Cannot open '$path': $!"; return; } my $reader = XML::LibXML::Reader->new(IO => $xmlin); unless ($reader) { carp "Cannot create reader using '$path'"; return; } while ($reader->nextElement('shipto')) { $INFO = $reader->readOuterXml(); print "$INFO\n"; } close $xmlin or carp "Cannot close '$path': $!"; return; }

but I have two problem in this script

1) I am extracting information from all XML files Having "shiporder" Node element, But in one XML file I have data with some other Node element "definition" I am not extracting that information, What should I do if I want to extract that information and store in the same variable.

2) After extracting all information That is stored in a $INFO varible, I want to store that $INFO variable information in one xml file how can I do that one. Please help me.


In reply to Re^4: Multiple XML files from Directory to One XML file using perl. by jyo
in thread Multiple XML files from Directory to One XML file using perl. by jyo

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.