> Now I'm trying to stores these files in an array and compare them.
> How can one store the entire file in an array?
XML is a tree structure and a single array isn't really designed to be the most intuitive or simple way to store a tree.

> Now I have to compare the two XML files
Comparing XML files is a problem many people need to solve these days so a CPAN search might help. After looking through the modules in the CPAN search results and some experimenting I came up with XML::SemanticDiff. The sample code and output might give further ideas on how the module might be applied to the posted problem.

use strict; use warnings; use XML::SemanticDiff; my $x = XML::SemanticDiff->new; my @diffs = $x->compare( <<EOXML_1, <top> <firstTag>abc</firstTag> <secondTag>def</secondTag> <thirdTag>ghi</thirdTag> </top> EOXML_1 <<EOXML_2 <top> <firstTag>abc</firstTag> <secondTag>456</secondTag> <lastTag>ghi</lastTag> </top> EOXML_2 ); foreach my $change (@diffs) { print "$change->{message}\n\tin XPath context $change->{context} +\n"; } __END__ Character differences in element 'secondTag'. in XPath context /top[1]/secondTag[1] Child element 'thirdTag' missing from element '/top[1]'. in XPath context /top[1] Rogue element 'lastTag' in element '/top[1]'. in XPath context /top[1]
Ron

In reply to Re: Comparing two XML files with XML::Simple using FOREACH and IF using by mr_ron
in thread Comparing two XML files with XML::Simple using FOREACH and IF using by gr.d

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.