i have two xml files like this
1. <xml> <chapter>sathish <subchap1>sathish is good boy or not <p>sathish is a good bou</p> </subchap1> </chapter> </xml> 2.<xml> <chapter>head <subchap1>body <p>para</p> </subchap1> </chapter> </xml>
this two xml files are my inputs i want the output as
<xml> <head>sathish <body>sathish is good boy or not <para>sathish is a good bou</para> <//body> </head> </xml> </code. i mean the second xml file contents are replaced to the first xml file + tags please help any one how can i do this i use the code as <code> #!/usr/bin/perl -w use warnings; use strict; use XML::Simple; use Data::Dumper; my %hash; my %hash1; my $file= $ARGV[0]; my $simple = XML::Simple->new(); my $hash = $simple->XMLin($file); my $file1= $ARGV[1]; my $hash1 = $simple->XMLin($file1); print Dumper ($hash); print Dumper ($hash1); my $areEqual=1; if(keys %hash == keys %hash1) { foreach my $key(keys %hash) { if(!exists $hash1{$key}) { $areEqual=0; last; } } } if($areEqual) { print "ARE "; } else { print "ARE NOT "; } for (keys %hash) { $hash{$_} = $hash1{$_} if exists $hash1{$_}; } print Dumper ($hash); print Dumper($hash1); $simple->XMLout($hash, KeepRoot => 1, OutputFile => 'pets.xml', XMLDecl => "<?xml version='1.0'?>", ); $simple->XMLout($hash1, KeepRoot => 1, OutputFile => 'pets1.xml', XMLDecl => "<?xml version='1.0'?>", );
this code converts the two xml files to hash value and compare the two hash keys are same if there are same keys replace the first hash keys with second hash values what is the error and please suggest me how can i do this

In reply to xml tag mapping? by satzbu

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.