Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

problem With adding node information to xml files.

by jyo (Initiate)
on Nov 21, 2011 at 17:28 UTC ( #939272=perlquestion: print w/ replies, xml ) Need Help??
jyo has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am Sorry for asking this question because I got some help form this site but I am struggling with this problem.

#!/usr/bin/perl use warnings; use strict; 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 an output file whose name won't be found by File::Find open( my $allxml, '>', "all_xml_contents.combined1.xml" ) or die "can't open output xml file for writing: $!\n"; print $allxml '<?xml version="1.0" encoding="UTF-8"?>', "\n<Shiporder xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instanc +e\">\n"; my %shipto_md5; find( sub { return unless ( /(_dtc\.xml)$/ and -f ); extract_information(); return; }, @ARGV ); print $allxml "</Shiporder>\n"; sub extract_information { my $path = $_; if ( my $reader = XML::LibXML::Reader->new( location => $path )) { while ( $reader->nextElement( 'shipto' )) { my $elem = $reader->readOuterXml(); my $md5 = md5( $elem ); print $allxml $reader->readOuterXml() unless ( $shipto_md5 +{$md5}++ ); } } return; }

In the above script by using md5, its deleting repeated node having same data, but if some files have repeated elements in the node by searching repeated one element how to remove total node information. help me with this problem.

Comment on problem With adding node information to xml files.
Download Code
Re: problem With adding node information to xml files.
by Anonymous Monk on Nov 21, 2011 at 17:35 UTC
Re: problem With adding node information to xml files.
by Anonymous Monk on Nov 21, 2011 at 17:44 UTC

      I readed all the information in perl introduction as you suggested, i can't find suitable logic, if you dont mine can you suggest me any other way or can you tel me is it possible?

        I readed all the information in perl introduction as you suggested, i can't find suitable logic, if you dont mine can you suggest me any other way or can you tel me is it possible?

        You keep saying the same thing, posting under different accounts, and ignoring any and all questions put to you, and the answers as well

        Why don't I believe you?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://939272]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-12-19 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (91 votes), past polls