Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to eliminate tag names in xml file using perl
    primarykey
    data
    text
    <p>I have multiple XML files in a folder,so I written script like this to combine into one xml file</p> <pre><code>#!/usr/bin/perl use warnings; use XML::LibXML; use Carp; use File::Find; use File::Spec::Functions qw( canonpath ); use XML::LibXML::Reader; use Digest::MD5 'md5'; if ( @ARGV == 0 ) { push @ARGV, "c:/main/work"; warn "Using default path $ARGV[0]\n Usage: $0 path ...\n"; } open( my $allxml, '&gt;', "all_xml_contents.combined.xml" ) or die "can't open output xml file for writing: $!\n"; print $allxml '&lt;?xml version="1.0" encoding="UTF-8"?&gt;', "\n&lt;Shiporder xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"&gt;\n"; my %shipto_md5; find( sub { return unless ( /(_stc\.xml)$/ and -f ); extract_information(); return; }, @ARGV ); print $allxml "&lt;/Shiporder&gt;\n"; sub extract_information { my $path = $_; if ( my $reader = XML::LibXML::Reader-&gt;new( location =&gt; $path )) { while ( $reader-&gt;nextElement( 'data' )) { my $elem = $reader-&gt;readOuterXml(); my $md5 = md5( $elem ); print $allxml $reader-&gt;readOuterXml() unless ( $shipto_md5{$md5}++ ); } } return; } </code></pre> <p>It printing all xml files into one xml like this.</p> <pre><code> all_xml.combined.xml &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;student specification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;student&gt; &lt;name&gt;johan&lt;/name&gt; &lt;/student&gt; &lt;student&gt; &lt;name&gt;benny&lt;/name&gt; &lt;/student&gt; &lt;student&gt; &lt;name&gt;kent&lt;/name&gt; &lt;/student&gt; &lt;/student specification&gt; </code></pre> <p>but I have one more node information in one xml file, i tried to extract that information like this in while loop.</p> <pre><code> $reader-&gt;nextElement( 'details' ); $information = $reader-&gt;readInnerXml(); </code></pre> <p>but how can i add this information to output file, please help me with this problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload